diff --git a/supervision/__init__.py b/supervision/__init__.py index 8fb015c9..a4126f31 100644 --- a/supervision/__init__.py +++ b/supervision/__init__.py @@ -67,8 +67,8 @@ from supervision.detection.utils import ( polygon_to_mask, polygon_to_xyxy, scale_boxes, - xywh_to_xyxy, xcycwh_to_xyxy, + xywh_to_xyxy, ) from supervision.draw.color import Color, ColorPalette from supervision.draw.utils import ( diff --git a/test/detection/test_utils.py b/test/detection/test_utils.py index a19a518a..9224c676 100644 --- a/test/detection/test_utils.py +++ b/test/detection/test_utils.py @@ -16,7 +16,9 @@ from supervision.detection.utils import ( merge_data, move_boxes, process_roboflow_result, - scale_boxes, xcycwh_to_xyxy, xywh_to_xyxy, + scale_boxes, + xcycwh_to_xyxy, + xywh_to_xyxy, ) TEST_MASK = np.zeros((1, 1000, 1000), dtype=bool) @@ -1095,35 +1097,20 @@ def test_contains_multiple_segments( @pytest.mark.parametrize( "xywh, expected_result", [ - ( - np.array([[10, 20, 30, 40]]), - np.array([[10, 20, 40, 60]]) - ), # standard case - ( - np.array([[0, 0, 0, 0]]), - np.array([[0, 0, 0, 0]]) - ), # zero size bounding box + (np.array([[10, 20, 30, 40]]), np.array([[10, 20, 40, 60]])), # standard case + (np.array([[0, 0, 0, 0]]), np.array([[0, 0, 0, 0]])), # zero size bounding box ( np.array([[50, 50, 100, 100]]), - np.array([[50, 50, 150, 150]]) + np.array([[50, 50, 150, 150]]), ), # large bounding box ( np.array([[-10, -20, 30, 40]]), - np.array([[-10, -20, 20, 20]]) + np.array([[-10, -20, 20, 20]]), ), # negative coordinates - ( - np.array([[50, 50, 0, 30]]), - np.array([[50, 50, 50, 80]]) - ), # zero width - ( - np.array([[50, 50, 20, 0]]), - np.array([[50, 50, 70, 50]]) - ), # zero height - ( - np.array([]).reshape(0, 4), - np.array([]).reshape(0, 4) - ), # empty array - ] + (np.array([[50, 50, 0, 30]]), np.array([[50, 50, 50, 80]])), # zero width + (np.array([[50, 50, 20, 0]]), np.array([[50, 50, 70, 50]])), # zero height + (np.array([]).reshape(0, 4), np.array([]).reshape(0, 4)), # empty array + ], ) def test_xywh_to_xyxy(xywh: np.ndarray, expected_result: np.ndarray) -> None: result = xywh_to_xyxy(xywh) @@ -1133,36 +1120,21 @@ def test_xywh_to_xyxy(xywh: np.ndarray, expected_result: np.ndarray) -> None: @pytest.mark.parametrize( "xcycwh, expected_result", [ - ( - np.array([[50, 50, 20, 30]]), - np.array([[40, 35, 60, 65]]) - ), # standard case - ( - np.array([[0, 0, 0, 0]]), - np.array([[0, 0, 0, 0]]) - ), # zero size bounding box + (np.array([[50, 50, 20, 30]]), np.array([[40, 35, 60, 65]])), # standard case + (np.array([[0, 0, 0, 0]]), np.array([[0, 0, 0, 0]])), # zero size bounding box ( np.array([[50, 50, 100, 100]]), - np.array([[0, 0, 100, 100]]) + np.array([[0, 0, 100, 100]]), ), # large bounding box centered at (50, 50) ( np.array([[-10, -10, 20, 30]]), - np.array([[-20, -25, 0, 5]]) + np.array([[-20, -25, 0, 5]]), ), # negative coordinates - ( - np.array([[50, 50, 0, 30]]), - np.array([[50, 35, 50, 65]]) - ), # zero width - ( - np.array([[50, 50, 20, 0]]), - np.array([[40, 50, 60, 50]]) - ), # zero height - ( - np.array([]).reshape(0, 4), - np.array([]).reshape(0, 4) - ), # empty array - ] + (np.array([[50, 50, 0, 30]]), np.array([[50, 35, 50, 65]])), # zero width + (np.array([[50, 50, 20, 0]]), np.array([[40, 50, 60, 50]])), # zero height + (np.array([]).reshape(0, 4), np.array([]).reshape(0, 4)), # empty array + ], ) def test_xcycwh_to_xyxy(xcycwh: np.ndarray, expected_result: np.ndarray) -> None: result = xcycwh_to_xyxy(xcycwh) - np.testing.assert_array_equal(result, expected_result) \ No newline at end of file + np.testing.assert_array_equal(result, expected_result)