Skip to content

Commit 99c73bf

Browse files
fix(pre_commit): 🎨 auto format pre-commit hooks
1 parent cc73ee9 commit 99c73bf

File tree

2 files changed

+23
-27
lines changed

2 files changed

+23
-27
lines changed

‎supervision/detection/line_zone.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ def __init__(
102102
self.vector = Vector(start=start, end=end)
103103
self.limits = self._calculate_region_of_interest_limits(vector=self.vector)
104104
self.crossing_history_length = max(2, minimum_crossing_threshold + 1)
105-
self.crossing_state_history: dict[tuple[int, int | None], deque[bool]] = defaultdict(
106-
lambda: deque(maxlen=self.crossing_history_length)
105+
self.crossing_state_history: dict[tuple[int, int | None], deque[bool]] = (
106+
defaultdict(lambda: deque(maxlen=self.crossing_history_length))
107107
)
108108
self._in_count_per_class: Counter = Counter()
109109
self._out_count_per_class: Counter = Counter()

‎test/detection/test_line_counter.py‎

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -805,15 +805,15 @@ def test_line_zone_long_horizon_disappearing_detections(
805805
[
806806
# Frame 1: Both objects on right side
807807
{
808-
"xyxy": [[2, 4, 4, 6], [6, 4, 8, 6]],
809-
"tracker_id": [1, 2],
810-
"class_id": [0, 1]
808+
"xyxy": [[2, 4, 4, 6], [6, 4, 8, 6]],
809+
"tracker_id": [1, 2],
810+
"class_id": [0, 1],
811811
},
812812
# Frame 2: Both objects cross to left side
813813
{
814-
"xyxy": [[2, -6, 4, -4], [6, -6, 8, -4]],
815-
"tracker_id": [1, 2],
816-
"class_id": [0, 1]
814+
"xyxy": [[2, -6, 4, -4], [6, -6, 8, -4]],
815+
"tracker_id": [1, 2],
816+
"class_id": [0, 1],
817817
},
818818
],
819819
[[False, False], [True, True]],
@@ -833,27 +833,25 @@ def test_line_zone_class_id_tracking(
833833
) -> None:
834834
"""Test that LineZone properly handles class_id changes during tracking."""
835835
line_zone = LineZone(
836-
start=vector.start,
837-
end=vector.end,
838-
triggering_anchors=[Position.CENTER]
836+
start=vector.start, end=vector.end, triggering_anchors=[Position.CENTER]
839837
)
840-
838+
841839
crossed_in_results = []
842840
crossed_out_results = []
843-
841+
844842
for frame in test_sequence:
845843
detections = mock_detections(**frame)
846844
crossed_in, crossed_out = line_zone.trigger(detections)
847845
crossed_in_results.append(list(crossed_in))
848846
crossed_out_results.append(list(crossed_out))
849-
847+
850848
assert crossed_in_results == expected_crossed_in
851849
assert crossed_out_results == expected_crossed_out
852-
850+
853851
# Check per-class counts
854852
for class_id, expected_count in expected_in_count_per_class.items():
855853
assert line_zone.in_count_per_class.get(class_id, 0) == expected_count
856-
854+
857855
for class_id, expected_count in expected_out_count_per_class.items():
858856
assert line_zone.out_count_per_class.get(class_id, 0) == expected_count
859857

@@ -888,16 +886,16 @@ def test_line_zone_class_id_with_minimum_threshold(
888886
) -> None:
889887
"""Test class_id changes work correctly with minimum crossing threshold."""
890888
line_zone = LineZone(
891-
start=vector.start,
889+
start=vector.start,
892890
end=vector.end,
893891
triggering_anchors=[Position.CENTER],
894-
minimum_crossing_threshold=minimum_crossing_threshold
892+
minimum_crossing_threshold=minimum_crossing_threshold,
895893
)
896-
894+
897895
for frame in test_sequence:
898896
detections = mock_detections(**frame)
899897
line_zone.trigger(detections)
900-
898+
901899
# Check final counts
902900
for class_id, expected_count in expected_final_counts.items():
903901
assert line_zone.in_count_per_class.get(class_id, 0) == expected_count
@@ -906,23 +904,21 @@ def test_line_zone_class_id_with_minimum_threshold(
906904
def test_line_zone_class_id_none_handling() -> None:
907905
"""Test LineZone handles None class_id values correctly."""
908906
line_zone = LineZone(
909-
start=Point(0, 0),
910-
end=Point(10, 0),
911-
triggering_anchors=[Position.CENTER]
907+
start=Point(0, 0), end=Point(10, 0), triggering_anchors=[Position.CENTER]
912908
)
913-
909+
914910
# Object with None class_id crosses the line
915911
test_sequence = [
916912
# Frame 1: Object on right side, no class_id
917913
{"xyxy": [[4, 4, 6, 6]], "tracker_id": [1], "class_id": None},
918914
# Frame 2: Object crosses to left side, still no class_id
919915
{"xyxy": [[4, -6, 6, -4]], "tracker_id": [1], "class_id": None},
920916
]
921-
917+
922918
for frame in test_sequence:
923919
detections = mock_detections(**frame)
924920
line_zone.trigger(detections)
925-
921+
926922
# Should work with None class_id
927923
assert line_zone.in_count_per_class[None] == 1
928-
assert line_zone.in_count == 1
924+
assert line_zone.in_count == 1

0 commit comments

Comments
 (0)