Skip to content

Commit 6128576

Browse files
fix(pre_commit): 🎨 auto format pre-commit hooks
1 parent cda5016 commit 6128576

File tree

5 files changed

+39
-41
lines changed

5 files changed

+39
-41
lines changed

‎examples/speed_estimation/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ supervision package for multiple tasks such as tracking, annotations, etc.
1111

1212
https://github.com/roboflow/supervision/assets/26109316/d50118c1-2ae4-458d-915a-5d860fd36f71
1313

14-
> [!IMPORTANT]
14+
> [!IMPORTANT]
1515
> Adjust the [`SOURCE`](https://github.com/roboflow/supervision/blob/e32b05a636dab2ea1f39299e529c4b22b8baa8da/examples/speed_estimation/ultralytics_example.py#L10)
1616
> and [`TARGET`](https://github.com/roboflow/supervision/blob/e32b05a636dab2ea1f39299e529c4b22b8baa8da/examples/speed_estimation/ultralytics_example.py#L15)
17-
> configuration if you plan to run a speed estimation script on your video file. Those must be adjusted separately for each camera view. You can learn more
17+
> configuration if you plan to run a speed estimation script on your video file. Those must be adjusted separately for each camera view. You can learn more
1818
> from our YouTube [tutorial](https://youtu.be/uWP6UjDeZvY).
1919
2020
## 💻 install

‎supervision/detection/line_counter.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
from typing import Dict, Optional, Tuple, List, Iterable
1+
from typing import Dict, Iterable, Optional, Tuple
22

33
import cv2
44
import numpy as np
55

66
from supervision.detection.core import Detections
77
from supervision.draw.color import Color
8-
from supervision.geometry.core import Point, Rect, Vector, Position
8+
from supervision.geometry.core import Point, Position, Rect, Vector
99

1010

1111
class LineZone:
@@ -34,8 +34,8 @@ def __init__(
3434
Position.TOP_LEFT,
3535
Position.TOP_RIGHT,
3636
Position.BOTTOM_LEFT,
37-
Position.BOTTOM_RIGHT
38-
)
37+
Position.BOTTOM_RIGHT,
38+
),
3939
):
4040
"""
4141
Args:
@@ -74,15 +74,15 @@ def calculate_region_of_interest_limits(vector: Vector) -> Tuple[Vector, Vector]
7474
start=vector.start,
7575
end=Point(
7676
x=vector.start.x + perpendicular_vector_x,
77-
y=vector.start.y + perpendicular_vector_y
78-
)
77+
y=vector.start.y + perpendicular_vector_y,
78+
),
7979
)
8080
end_region_limit = Vector(
8181
start=vector.end,
8282
end=Point(
8383
x=vector.end.x - perpendicular_vector_x,
84-
y=vector.end.y - perpendicular_vector_y
85-
)
84+
y=vector.end.y - perpendicular_vector_y,
85+
),
8686
)
8787
return start_region_limit, end_region_limit
8888

@@ -112,31 +112,31 @@ def trigger(self, detections: Detections) -> Tuple[np.ndarray, np.ndarray]:
112112
if len(detections) == 0:
113113
return crossed_in, crossed_out
114114

115-
all_anchors = np.array([
116-
detections.get_anchors_coordinates(anchor)
117-
for anchor
118-
in self.triggering_anchors
119-
])
115+
all_anchors = np.array(
116+
[
117+
detections.get_anchors_coordinates(anchor)
118+
for anchor in self.triggering_anchors
119+
]
120+
)
120121

121122
for i, tracker_id in enumerate(detections.tracker_id):
122123
if tracker_id is None:
123124
continue
124125

125126
box_anchors = [Point(x=x, y=y) for x, y in all_anchors[:, i, :]]
126127

127-
in_limits = all([
128-
self.is_point_in_limits(point=anchor, limits=self.limits)
129-
for anchor
130-
in box_anchors
131-
])
128+
in_limits = all(
129+
[
130+
self.is_point_in_limits(point=anchor, limits=self.limits)
131+
for anchor in box_anchors
132+
]
133+
)
132134

133135
if not in_limits:
134136
continue
135137

136138
triggers = [
137-
self.vector.cross_product(point=anchor) > 0
138-
for anchor
139-
in box_anchors
139+
self.vector.cross_product(point=anchor) > 0 for anchor in box_anchors
140140
]
141141

142142
if len(set(triggers)) == 2:
@@ -323,4 +323,4 @@ def annotate(self, frame: np.ndarray, line_counter: LineZone) -> np.ndarray:
323323
self.text_thickness,
324324
cv2.LINE_AA,
325325
)
326-
return frame
326+
return frame

‎supervision/geometry/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def magnitude(self) -> float:
5454
"""
5555
dx = self.end.x - self.start.x
5656
dy = self.end.y - self.start.y
57-
return sqrt(dx ** 2 + dy ** 2)
57+
return sqrt(dx**2 + dy**2)
5858

5959
def cross_product(self, point: Point) -> float:
6060
"""

‎test/detection/test_line_counter.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from contextlib import ExitStack as DoesNotRaise
2-
from typing import Tuple, Optional
2+
from typing import Optional, Tuple
33

44
import pytest
55

66
from supervision import LineZone
7-
from supervision.geometry.core import Vector, Point
7+
from supervision.geometry.core import Point, Vector
88

99

1010
@pytest.mark.parametrize(
@@ -13,59 +13,59 @@
1313
(
1414
Vector(start=Point(x=0.0, y=0.0), end=Point(x=0.0, y=0.0)),
1515
None,
16-
pytest.raises(ValueError)
16+
pytest.raises(ValueError),
1717
),
1818
(
1919
Vector(start=Point(x=1.0, y=1.0), end=Point(x=1.0, y=1.0)),
2020
None,
21-
pytest.raises(ValueError)
21+
pytest.raises(ValueError),
2222
),
2323
(
2424
Vector(start=Point(x=0.0, y=0.0), end=Point(x=0.0, y=4.0)),
2525
(
2626
Vector(start=Point(x=0.0, y=0.0), end=Point(x=-1.0, y=0.0)),
27-
Vector(start=Point(x=0.0, y=4.0), end=Point(x=1.0, y=4.0))
27+
Vector(start=Point(x=0.0, y=4.0), end=Point(x=1.0, y=4.0)),
2828
),
2929
DoesNotRaise(),
3030
),
3131
(
3232
Vector(Point(0.0, 0.0), Point(4.0, 0.0)),
3333
(
3434
Vector(start=Point(x=0.0, y=0.0), end=Point(x=0.0, y=1.0)),
35-
Vector(start=Point(x=4.0, y=0.0), end=Point(x=4.0, y=-1.0))
35+
Vector(start=Point(x=4.0, y=0.0), end=Point(x=4.0, y=-1.0)),
3636
),
3737
DoesNotRaise(),
3838
),
3939
(
4040
Vector(Point(0.0, 0.0), Point(3.0, 4.0)),
4141
(
4242
Vector(start=Point(x=0, y=0), end=Point(x=-0.8, y=0.6)),
43-
Vector(start=Point(x=3, y=4), end=Point(x=3.8, y=3.4))
43+
Vector(start=Point(x=3, y=4), end=Point(x=3.8, y=3.4)),
4444
),
4545
DoesNotRaise(),
4646
),
4747
(
4848
Vector(Point(0.0, 0.0), Point(4.0, 3.0)),
4949
(
5050
Vector(start=Point(x=0, y=0), end=Point(x=-0.6, y=0.8)),
51-
Vector(start=Point(x=4, y=3), end=Point(x=4.6, y=2.2))
51+
Vector(start=Point(x=4, y=3), end=Point(x=4.6, y=2.2)),
5252
),
5353
DoesNotRaise(),
5454
),
5555
(
5656
Vector(Point(0.0, 0.0), Point(3.0, -4.0)),
5757
(
5858
Vector(start=Point(x=0, y=0), end=Point(x=0.8, y=0.6)),
59-
Vector(start=Point(x=3, y=-4), end=Point(x=2.2, y=-4.6))
59+
Vector(start=Point(x=3, y=-4), end=Point(x=2.2, y=-4.6)),
6060
),
6161
DoesNotRaise(),
62-
)
63-
]
62+
),
63+
],
6464
)
6565
def test_calculate_region_of_interest_limits(
6666
vector: Vector,
6767
expected_result: Optional[Tuple[Vector, Vector]],
68-
exception: Exception
68+
exception: Exception,
6969
) -> None:
7070
with exception:
7171
result = LineZone.calculate_region_of_interest_limits(vector=vector)

‎test/geometry/test_core.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727
],
2828
)
2929
def test_vector_cross_product(
30-
vector: Vector,
31-
point: Point,
32-
expected_result: float
30+
vector: Vector, point: Point, expected_result: float
3331
) -> None:
3432
result = vector.cross_product(point=point)
3533
assert result == expected_result
@@ -54,7 +52,7 @@ def test_vector_cross_product(
5452
(Vector(start=Point(x=0, y=0), end=Point(x=4, y=3)), 5.0),
5553
(Vector(start=Point(x=3, y=4), end=Point(x=0, y=0)), 5.0),
5654
(Vector(start=Point(x=4, y=3), end=Point(x=0, y=0)), 5.0),
57-
]
55+
],
5856
)
5957
def test_vector_magnitude(vector: Vector, expected_result: float) -> None:
6058
result = vector.magnitude

0 commit comments

Comments
 (0)