From 4fbec12b06ee24abf35c71de9f995f472860651d Mon Sep 17 00:00:00 2001 From: James Gallagher Date: Wed, 1 Feb 2023 14:37:54 +0000 Subject: [PATCH] run linter --- supervision/draw/utils.py | 2 +- supervision/tools/detections.py | 6 +++--- supervision/tools/line_counter.py | 5 +++-- test/draw/test_color.py | 34 +++++++++++++++---------------- test/geometry/test_dataclasses.py | 15 +++----------- 5 files changed, 26 insertions(+), 36 deletions(-) diff --git a/supervision/draw/utils.py b/supervision/draw/utils.py index ff9e60b8..ff6c050c 100644 --- a/supervision/draw/utils.py +++ b/supervision/draw/utils.py @@ -83,7 +83,7 @@ def draw_filled_rectangle(scene: np.ndarray, rect: Rect, color: Color) -> np.nda ```python >>> # TODO: Add example ``` - + """ cv2.rectangle( scene, diff --git a/supervision/tools/detections.py b/supervision/tools/detections.py index 72a8edd8..4faaf6cf 100644 --- a/supervision/tools/detections.py +++ b/supervision/tools/detections.py @@ -72,13 +72,13 @@ class Detections: Attributes: yolov5_output (np.ndarray): The output tensor from YOLOv5 - + Returns: Example: ```python >>> from supervision.tools.detections import Detections - + >>> detections = Detections.from_yolov5(yolov5_output) ``` """ @@ -154,7 +154,7 @@ class BoxAnnotator: ) -> np.ndarray: """ Draws bounding boxes on the frame using the detections provided. - + Attributes: frame (np.ndarray): The image on which the bounding boxes will be drawn detections (Detections): The detections for which the bounding boxes will be drawn diff --git a/supervision/tools/line_counter.py b/supervision/tools/line_counter.py index 93a4e0c5..f791c9a6 100644 --- a/supervision/tools/line_counter.py +++ b/supervision/tools/line_counter.py @@ -12,6 +12,7 @@ class LineCounter: """ Count the number of objects that cross a line. """ + def __init__(self, start: Point, end: Point): """ Initialize a LineCounter object. @@ -92,7 +93,7 @@ class LineCounterAnnotator: text_scale (float): The scale of the text that will be drawn. text_offset (float): The offset of the text that will be drawn. text_padding (int): The padding of the text that will be drawn. - + """ self.thickness: float = thickness self.color: Color = color @@ -112,7 +113,7 @@ class LineCounterAnnotator: Returns: np.ndarray: The image with the line drawn on it. - + """ cv2.line( frame, diff --git a/test/draw/test_color.py b/test/draw/test_color.py index 5ea48abb..723f7043 100644 --- a/test/draw/test_color.py +++ b/test/draw/test_color.py @@ -7,27 +7,25 @@ from supervision.draw.color import Color @pytest.mark.parametrize( - 'color_hex, expected_result, exception', + "color_hex, expected_result, exception", [ - ('fff', Color.white(), DoesNotRaise()), - ('#fff', Color.white(), DoesNotRaise()), - ('ffffff', Color.white(), DoesNotRaise()), - ('#ffffff', Color.white(), DoesNotRaise()), - ('f00', Color.red(), DoesNotRaise()), - ('0f0', Color.green(), DoesNotRaise()), - ('00f', Color.blue(), DoesNotRaise()), - ('#808000', Color(r=128, g=128, b=0), DoesNotRaise()), - ('', None, pytest.raises(ValueError)), - ('00', None, pytest.raises(ValueError)), - ('0000', None, pytest.raises(ValueError)), - ('0000000', None, pytest.raises(ValueError)), - ('ffg', None, pytest.raises(ValueError)), - ] + ("fff", Color.white(), DoesNotRaise()), + ("#fff", Color.white(), DoesNotRaise()), + ("ffffff", Color.white(), DoesNotRaise()), + ("#ffffff", Color.white(), DoesNotRaise()), + ("f00", Color.red(), DoesNotRaise()), + ("0f0", Color.green(), DoesNotRaise()), + ("00f", Color.blue(), DoesNotRaise()), + ("#808000", Color(r=128, g=128, b=0), DoesNotRaise()), + ("", None, pytest.raises(ValueError)), + ("00", None, pytest.raises(ValueError)), + ("0000", None, pytest.raises(ValueError)), + ("0000000", None, pytest.raises(ValueError)), + ("ffg", None, pytest.raises(ValueError)), + ], ) def test_color_from_hex( - color_hex, - expected_result: Optional[Color], - exception: Exception + color_hex, expected_result: Optional[Color], exception: Exception ) -> None: with exception: result = Color.from_hex(color_hex=color_hex) diff --git a/test/geometry/test_dataclasses.py b/test/geometry/test_dataclasses.py index 5e829877..34821884 100644 --- a/test/geometry/test_dataclasses.py +++ b/test/geometry/test_dataclasses.py @@ -4,37 +4,28 @@ from supervision.geometry.dataclasses import Vector, Point @pytest.mark.parametrize( - 'vector, point, expected_result', + "vector, point, expected_result", [ (Vector(start=Point(x=0, y=0), end=Point(x=5, y=5)), Point(x=-1, y=1), False), (Vector(start=Point(x=0, y=0), end=Point(x=5, y=5)), Point(x=6, y=6), False), (Vector(start=Point(x=0, y=0), end=Point(x=5, y=5)), Point(x=3, y=6), False), - (Vector(start=Point(x=5, y=5), end=Point(x=0, y=0)), Point(x=-1, y=1), True), (Vector(start=Point(x=5, y=5), end=Point(x=0, y=0)), Point(x=6, y=6), False), (Vector(start=Point(x=5, y=5), end=Point(x=0, y=0)), Point(x=3, y=6), True), - (Vector(start=Point(x=0, y=0), end=Point(x=1, y=0)), Point(x=0, y=0), False), (Vector(start=Point(x=0, y=0), end=Point(x=1, y=0)), Point(x=0, y=-1), True), (Vector(start=Point(x=0, y=0), end=Point(x=1, y=0)), Point(x=0, y=1), False), - (Vector(start=Point(x=1, y=0), end=Point(x=0, y=0)), Point(x=0, y=0), False), (Vector(start=Point(x=1, y=0), end=Point(x=0, y=0)), Point(x=0, y=-1), False), (Vector(start=Point(x=1, y=0), end=Point(x=0, y=0)), Point(x=0, y=1), True), - (Vector(start=Point(x=1, y=1), end=Point(x=1, y=3)), Point(x=0, y=0), False), (Vector(start=Point(x=1, y=1), end=Point(x=1, y=3)), Point(x=1, y=4), False), (Vector(start=Point(x=1, y=1), end=Point(x=1, y=3)), Point(x=2, y=4), True), - (Vector(start=Point(x=1, y=3), end=Point(x=1, y=1)), Point(x=0, y=0), True), (Vector(start=Point(x=1, y=3), end=Point(x=1, y=1)), Point(x=1, y=4), False), (Vector(start=Point(x=1, y=3), end=Point(x=1, y=1)), Point(x=2, y=4), False), - ] + ], ) -def test_vector_is_in( - vector: Vector, - point: Point, - expected_result: bool -) -> None: +def test_vector_is_in(vector: Vector, point: Point, expected_result: bool) -> None: result = vector.is_in(point=point) assert result == expected_result