From 6b5dacd8e3d4bfe8742c193d68fe4bbf235a7966 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 6 May 2024 22:22:47 +0000 Subject: [PATCH] =?UTF-8?q?fix(pre=5Fcommit):=20=F0=9F=8E=A8=20auto=20form?= =?UTF-8?q?at=20pre-commit=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/dataset/test_utils.py | 65 ++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/test/dataset/test_utils.py b/test/dataset/test_utils.py index 9cefa438..58f2ec22 100644 --- a/test/dataset/test_utils.py +++ b/test/dataset/test_utils.py @@ -10,10 +10,10 @@ from supervision import Detections from supervision.dataset.utils import ( build_class_index_mapping, map_detections_class_id, - merge_class_lists, - train_test_split, mask_to_rle, + merge_class_lists, rle_to_mask, + train_test_split, ) T = TypeVar("T") @@ -239,33 +239,37 @@ def test_map_detections_class_id( "mask, expected_rle, exception", [ ( - np.zeros((3,3)).astype(bool), + np.zeros((3, 3)).astype(bool), [9], DoesNotRaise(), ), # mask with background only (mask with only False values) ( - np.ones((3,3)).astype(bool), + np.ones((3, 3)).astype(bool), [0, 9], DoesNotRaise(), ), # mask with foreground only (mask with only True values) ( np.array( - [[0, 0, 0, 0, 0], - [0, 1, 1, 1, 0], - [0, 1, 0, 1, 0], - [0, 1, 1, 1, 0], - [0, 0, 0, 0, 0]] + [ + [0, 0, 0, 0, 0], + [0, 1, 1, 1, 0], + [0, 1, 0, 1, 0], + [0, 1, 1, 1, 0], + [0, 0, 0, 0, 0], + ] ).astype(bool), [6, 3, 2, 1, 1, 1, 2, 3, 6], DoesNotRaise(), ), # mask where foreground object has hole ( np.array( - [[1, 0, 1, 0, 1], - [1, 0, 1, 0, 1], - [1, 0, 1, 0, 1], - [1, 0, 1, 0, 1], - [1, 0, 1, 0, 1]] + [ + [1, 0, 1, 0, 1], + [1, 0, 1, 0, 1], + [1, 0, 1, 0, 1], + [1, 0, 1, 0, 1], + [1, 0, 1, 0, 1], + ] ).astype(bool), [0, 5, 5, 5, 5, 5], DoesNotRaise(), @@ -286,24 +290,26 @@ def test_mask_to_rle_convertion( ( [9], [3, 3], - np.zeros((3,3)).astype(bool), + np.zeros((3, 3)).astype(bool), DoesNotRaise(), ), # mask with background only (mask with only False values) ( [0, 9], [3, 3], - np.ones((3,3)).astype(bool), + np.ones((3, 3)).astype(bool), DoesNotRaise(), ), # mask with foreground only (mask with only True values) ( [6, 3, 2, 1, 1, 1, 2, 3, 6], [5, 5], np.array( - [[0, 0, 0, 0, 0], - [0, 1, 1, 1, 0], - [0, 1, 0, 1, 0], - [0, 1, 1, 1, 0], - [0, 0, 0, 0, 0]] + [ + [0, 0, 0, 0, 0], + [0, 1, 1, 1, 0], + [0, 1, 0, 1, 0], + [0, 1, 1, 1, 0], + [0, 0, 0, 0, 0], + ] ).astype(bool), DoesNotRaise(), ), # mask where foreground object has hole @@ -311,18 +317,23 @@ def test_mask_to_rle_convertion( [0, 5, 5, 5, 5, 5], [5, 5], np.array( - [[1, 0, 1, 0, 1], - [1, 0, 1, 0, 1], - [1, 0, 1, 0, 1], - [1, 0, 1, 0, 1], - [1, 0, 1, 0, 1]] + [ + [1, 0, 1, 0, 1], + [1, 0, 1, 0, 1], + [1, 0, 1, 0, 1], + [1, 0, 1, 0, 1], + [1, 0, 1, 0, 1], + ] ).astype(bool), DoesNotRaise(), ), # mask where foreground consists of 3 separate components ], ) def test_rle_to_mask_convertion( - rle: npt.NDArray[np.int_], resolution_wh: Tuple[int, int],expected_mask: npt.NDArray[np.bool_], exception: Exception + rle: npt.NDArray[np.int_], + resolution_wh: Tuple[int, int], + expected_mask: npt.NDArray[np.bool_], + exception: Exception, ) -> None: with exception: result = rle_to_mask(rle=rle, resolution_wh=resolution_wh)