Skip to content

Commit 1cdeccd

Browse files
Fix formatting and fix a bug in label mapping
Signed-off-by: Albert van Houten <[email protected]>
1 parent 96be71e commit 1cdeccd

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

library/src/otx/data/dataset/base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,13 @@ def get_idx_list_per_classes(self, use_string_label: bool = False) -> dict[int |
158158
"""Get a dictionary mapping class labels to lists of corresponding sample indices.
159159
160160
Args:
161-
use_string_label (bool, optional): If True, use string labels as keys; otherwise, use integer labels. Defaults to False.
161+
use_string_label (bool, optional): If True, use string labels as keys; otherwise, use integer labels.
162162
163163
Returns:
164-
dict[int | str, list[int]]: A dictionary where each key is a class label (int or str) and each value is a list of sample indices belonging to that class.
164+
dict[int | str, list[int]]: A dictionary where each key is a class label (int or str) and each value is a
165+
list of sample indices belonging to that class.
165166
"""
167+
166168
@property
167169
def task_type(self) -> OTXTaskType | None:
168170
"""OTX Task Type for the dataset. Can be None if no task is defined."""

library/src/otx/types/label.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,8 @@ def from_dm_label_groups_arrow(cls, dm_label_categories: HierarchicalLabelCatego
360360
id_to_name_mapping = {item.name: label_names[i] for i, item in enumerate(dm_label_categories.items)}
361361

362362
for i, item in enumerate(dm_label_categories.items):
363-
object.__setattr__(dm_label_categories, "name", label_names[i])
364-
object.__setattr__(dm_label_categories, "parent", id_to_name_mapping.get(item.parent, item.parent))
363+
object.__setattr__(item, "name", label_names[i])
364+
object.__setattr__(item, "parent", id_to_name_mapping.get(item.parent, item.parent))
365365

366366
for label_group in dm_label_categories.label_groups:
367367
object.__setattr__(

0 commit comments

Comments
 (0)