fix(formatter): apply fixes from ruff and fix minor mypy and pep corrections

Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
This commit is contained in:
Onuralp SEZER committed 2024-08-23 19:45:38 +03:00
1 parent b65d2cc73f
commit a64a2fc243
12 files changed
+19 -18

No files matched your search

Vendored
+1 -1
View File
@@ -972,7 +972,7 @@
}
],
"source": [
"from supervision.assets import download_assets, VideoAssets\n",
"from supervision.assets import VideoAssets, download_assets\n",
"\n",
"download_assets(VideoAssets.VEHICLES)\n",
"VIDEO_PATH = VideoAssets.VEHICLES.value"
+1 -1
View File
@@ -1,5 +1,4 @@
from contextlib import ExitStack as DoesNotRaise
from test.test_utils import mock_detections
from typing import Optional
import numpy as np
@@ -7,6 +6,7 @@ import pytest
from supervision.annotators.utils import ColorLookup, resolve_color_idx
from supervision.detection.core import Detections
from test.test_utils import mock_detections
@pytest.mark.parametrize(
+6 -6
View File
@@ -1,16 +1,16 @@
from contextlib import ExitStack as DoesNotRaise
from test.test_utils import mock_detections
from typing import List, Optional
import defusedxml.ElementTree as ET
import numpy as np
import pytest
from defusedxml import ElementTree
from supervision.dataset.formats.pascal_voc import (
detections_from_xml_obj,
object_to_pascal_voc,
parse_polygon_points,
)
from test.test_utils import mock_detections
def are_xml_elements_equal(elem1, elem2):
@@ -36,7 +36,7 @@ def are_xml_elements_equal(elem1, elem2):
np.array([0, 0, 10, 10]),
"test",
None,
ET.fromstring(
ElementTree.fromstring(
"""<object><name>test</name><bndbox><xmin>1</xmin><ymin>1</ymin>
<xmax>11</xmax><ymax>11</ymax></bndbox></object>"""
),
@@ -46,7 +46,7 @@ def are_xml_elements_equal(elem1, elem2):
np.array([0, 0, 10, 10]),
"test",
np.array([[0, 0], [10, 0], [10, 10], [0, 10]]),
ET.fromstring(
ElementTree.fromstring(
"""<object><name>test</name><bndbox><xmin>1</xmin><ymin>1</ymin>
<xmax>11</xmax><ymax>11</ymax>
</bndbox><polygon><x1>1</x1><y1>1</y1><x2>11</x2>
@@ -73,7 +73,7 @@ def test_object_to_pascal_voc(
"polygon_element, expected_result, exception",
[
(
ET.fromstring(
ElementTree.fromstring(
"""<polygon><x1>0</x1><y1>0</y1><x2>10</x2><y2>0</y2><x3>10</x3>
<y3>10</y3><x4>0</x4><y4>10</y4></polygon>"""
),
@@ -160,6 +160,6 @@ def test_detections_from_xml_obj(
xml_string, classes, resolution_wh, force_masks, expected_result, exception
):
with exception:
root = ET.fromstring(xml_string)
root = ElementTree.fromstring(xml_string)
result, _ = detections_from_xml_obj(root, classes, resolution_wh, force_masks)
assert result == expected_result
+1 -1
View File
@@ -1,11 +1,11 @@
from contextlib import ExitStack as DoesNotRaise
from test.test_utils import mock_detections
from typing import List, Optional
import numpy as np
import pytest
from supervision import DetectionDataset
from test.test_utils import mock_detections
@pytest.mark.parametrize(
+1 -1
View File
@@ -1,5 +1,4 @@
from contextlib import ExitStack as DoesNotRaise
from test.test_utils import mock_detections
from typing import Dict, List, Optional, Tuple, TypeVar
import numpy as np
@@ -15,6 +14,7 @@ from supervision.dataset.utils import (
rle_to_mask,
train_test_split,
)
from test.test_utils import mock_detections
T = TypeVar("T")
+1 -1
View File
@@ -1,5 +1,4 @@
from contextlib import ExitStack as DoesNotRaise
from test.test_utils import mock_detections
from typing import List, Optional, Union
import numpy as np
@@ -7,6 +6,7 @@ import pytest
from supervision.detection.core import Detections, merge_inner_detection_object_pair
from supervision.geometry.core import Position
from test.test_utils import mock_detections
PREDICTIONS = np.array(
[
+1 -1
View File
@@ -1,11 +1,11 @@
import csv
import os
from test.test_utils import mock_detections
from typing import Any, Dict, List
import pytest
import supervision as sv
from test.test_utils import mock_detections
@pytest.mark.parametrize(
+1 -1
View File
@@ -1,11 +1,11 @@
import json
import os
from test.test_utils import mock_detections
from typing import Any, Dict, List
import pytest
import supervision as sv
from test.test_utils import mock_detections
@pytest.mark.parametrize(
+1 -1
View File
@@ -1,11 +1,11 @@
from contextlib import ExitStack as DoesNotRaise
from test.test_utils import mock_detections
from typing import List, Optional, Tuple
import pytest
from supervision import LineZone
from supervision.geometry.core import Point, Position, Vector
from test.test_utils import mock_detections
@pytest.mark.parametrize(
+1 -1
View File
@@ -1,10 +1,10 @@
from contextlib import ExitStack as DoesNotRaise
from test.test_utils import mock_detections
import numpy as np
import pytest
import supervision as sv
from test.test_utils import mock_detections
DETECTION_BOXES = np.array(
[
+1 -1
View File
@@ -1,5 +1,4 @@
from contextlib import ExitStack as DoesNotRaise
from test.test_utils import assert_almost_equal, mock_detections
from typing import Optional, Union
import numpy as np
@@ -11,6 +10,7 @@ from supervision.metrics.detection import (
MeanAveragePrecision,
detections_to_tensor,
)
from test.test_utils import assert_almost_equal, mock_detections
CLASSES = np.arange(80)
NUM_CLASSES = len(CLASSES)
+3 -2
View File
@@ -1,13 +1,14 @@
from typing import Any, Dict, List, Optional
import numpy as np
import numpy.typing as npt
from supervision.detection.core import Detections
from supervision.keypoint.core import KeyPoints
def mock_detections(
xyxy: List[List[float]],
xyxy: npt.NDArray[np.float32],
mask: Optional[List[np.ndarray]] = None,
confidence: Optional[List[float]] = None,
class_id: Optional[List[int]] = None,
@@ -32,7 +33,7 @@ def mock_detections(
def mock_keypoints(
xy: List[List[float]],
xy: npt.NDArray[np.float32],
confidence: Optional[List[float]] = None,
class_id: Optional[List[int]] = None,
data: Optional[Dict[str, List[Any]]] = None,