Skip to content

Commit

Permalink
Fix issue spotted while testing
Browse files Browse the repository at this point in the history
  • Loading branch information
PawelPeczek-Roboflow committed Jan 27, 2025
1 parent 99d4f4d commit 9e738d2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def _pick_detections_by_parent_class(
parent_class: str,
) -> sv.Detections:
class_names = detections.data.get("class_name")
if not class_names:
if class_names is None or len(class_names) == 0:
return sv.Detections.empty()
if not isinstance(class_names, np.ndarray):
class_names = np.array(class_names)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def test_picking_detections_by_parent_class_when_parent_class_not_fond() -> None
),
class_id=np.array([0, 1]),
confidence=np.array([0.3, 0.4]),
data={"class_name": ["c", "d"]},
data={"class_name": np.array(["c", "d"])},
)

# when
Expand All @@ -166,7 +166,7 @@ def test_picking_detections_by_parent_class_when_no_child_detections_matching()
),
class_id=np.array([0, 0, 1]),
confidence=np.array([0.3, 0.4, 0.5]),
data={"class_name": ["a", "a", "b"]},
data={"class_name": np.array(["a", "a", "b"])},
)

# when
Expand All @@ -191,7 +191,7 @@ def test_picking_detections_by_parent_class_when_there_are_child_detections_matc
),
class_id=np.array([0, 1, 1]),
confidence=np.array([0.3, 0.4, 0.5]),
data={"class_name": ["a", "b", "b"]},
data={"class_name": np.array(["a", "b", "b"])},
)

# when
Expand Down Expand Up @@ -220,7 +220,7 @@ def test_picking_detections_by_parent_class_when_there_are_child_detections_matc
),
class_id=np.array([0, 1, 1, 0, 2]),
confidence=np.array([0.3, 0.4, 0.5, 0.6, 0.7]),
data={"class_name": ["a", "b", "b", "a", "c"]},
data={"class_name": np.array(["a", "b", "b", "a", "c"])},
)

# when
Expand Down

0 comments on commit 9e738d2

Please sign in to comment.