# task_utils

Python API: `luxonis_ml.data.utils.task_utils`

## Functions

### get_task_name

```python
def get_task_name(task: str) -> str:
```

Return the task name from a task string.

> **Examples**
> ```pycon
>>> get_task_name("detector/boundingbox")
'detector'
>>> get_task_name("classification")
'classification'
```

Parameters

 * `task` (`str`): Task string.

Returns

 * `str`: Task name.

### get_task_type

```python
def get_task_type(task: str) -> str:
```

Return the task type from a task string.

> **Example**
> ```pycon
>>> get_task_type("task_name/type")
'type'
>>> get_task_type("metadata/name")
'metadata/name'
>>> get_task_type("task_name/metadata/name")
'metadata/name'
```

Parameters

 * `task` (`str`): Task string, such as `"task_name/type"`.

Returns

 * `str`: Task type. Metadata tasks are returned as `"metadata/type"`.

### split_task

```python
def split_task(task: str) -> tuple[str, str]:
```

Split a task into task name and task type.

> **Examples**
> ```pycon
>>> split_task("detector/boundingbox")
('detector', 'boundingbox')
>>> split_task("classification")
('', 'classification')
```

Parameters

 * `task` (`str`): Task to split.

Returns

 * `tuple[str, str]`: Task name and task type.

### task_is_metadata

```python
def task_is_metadata(task: str) -> bool:
```

Check whether a task is a metadata task.

> **Examples**
> ```pycon
>>> task_is_metadata("metadata/weather")
True
>>> task_is_metadata("camera/metadata/weather")
True
>>> task_is_metadata("camera/boundingbox")
False
```

Parameters

 * `task` (`str`): Task to check.

Returns

 * `bool`: Whether the task is a metadata task.

### task_type_iterator

```python
def task_type_iterator(labels: Labels, task_type: TaskType) -> Iterator[tuple[str, np.ndarray]]:
```

Iterate over labels of a specific task type.

> **Examples**
> ```pycon
>>> labels = {
...     "detector/boundingbox": np.array([1]),
...     "pose/keypoints": np.array([2]),
... }
>>> [(task, arr.tolist()) for task, arr in task_type_iterator(labels, "keypoints")]
[('pose/keypoints', [2])]
```

Parameters

 * `labels` (`Labels`): Labels to iterate over.
 * `task_type` (`TaskType`): Label type to yield.

Returns

 * `Iterator[tuple[str, np.ndarray]]`: Iterator over matching labels.
