fix: fix test warnings
This commit is contained in:
+20
-48
@@ -1,7 +1,6 @@
|
||||
from contextlib import ExitStack as DoesNotRaise
|
||||
from typing import List, Optional
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from supervision import DetectionDataset
|
||||
@@ -13,29 +12,29 @@ from test.test_utils import mock_detections
|
||||
[
|
||||
(
|
||||
[],
|
||||
DetectionDataset(classes=[], images={}, annotations={}),
|
||||
DetectionDataset(classes=[], images=[], annotations={}),
|
||||
DoesNotRaise(),
|
||||
), # empty dataset list
|
||||
(
|
||||
[DetectionDataset(classes=[], images={}, annotations={})],
|
||||
DetectionDataset(classes=[], images={}, annotations={}),
|
||||
[DetectionDataset(classes=[], images=[], annotations={})],
|
||||
DetectionDataset(classes=[], images=[], annotations={}),
|
||||
DoesNotRaise(),
|
||||
), # single empty dataset
|
||||
(
|
||||
[
|
||||
DetectionDataset(classes=["dog", "person"], images={}, annotations={}),
|
||||
DetectionDataset(classes=["dog", "person"], images={}, annotations={}),
|
||||
DetectionDataset(classes=["dog", "person"], images=[], annotations={}),
|
||||
DetectionDataset(classes=["dog", "person"], images=[], annotations={}),
|
||||
],
|
||||
DetectionDataset(classes=["dog", "person"], images={}, annotations={}),
|
||||
DetectionDataset(classes=["dog", "person"], images=[], annotations={}),
|
||||
DoesNotRaise(),
|
||||
), # two datasets; no images and annotations, the same classes
|
||||
(
|
||||
[
|
||||
DetectionDataset(classes=["dog", "person"], images={}, annotations={}),
|
||||
DetectionDataset(classes=["cat"], images={}, annotations={}),
|
||||
DetectionDataset(classes=["dog", "person"], images=[], annotations={}),
|
||||
DetectionDataset(classes=["cat"], images=[], annotations={}),
|
||||
],
|
||||
DetectionDataset(
|
||||
classes=["cat", "dog", "person"], images={}, annotations={}
|
||||
classes=["cat", "dog", "person"], images=[], annotations={}
|
||||
),
|
||||
DoesNotRaise(),
|
||||
), # two datasets; no images and annotations, different classes
|
||||
@@ -43,10 +42,7 @@ from test.test_utils import mock_detections
|
||||
[
|
||||
DetectionDataset(
|
||||
classes=["dog", "person"],
|
||||
images={
|
||||
"image-1.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
"image-2.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
},
|
||||
images=["image-1.png", "image-2.png"],
|
||||
annotations={
|
||||
"image-1.png": mock_detections(
|
||||
xyxy=[[0, 0, 10, 10]], class_id=[0]
|
||||
@@ -56,14 +52,11 @@ from test.test_utils import mock_detections
|
||||
),
|
||||
},
|
||||
),
|
||||
DetectionDataset(classes=[], images={}, annotations={}),
|
||||
DetectionDataset(classes=[], images=[], annotations={}),
|
||||
],
|
||||
DetectionDataset(
|
||||
classes=["dog", "person"],
|
||||
images={
|
||||
"image-1.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
"image-2.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
},
|
||||
images=["image-1.png", "image-2.png"],
|
||||
annotations={
|
||||
"image-1.png": mock_detections(xyxy=[[0, 0, 10, 10]], class_id=[0]),
|
||||
"image-2.png": mock_detections(xyxy=[[0, 0, 10, 10]], class_id=[1]),
|
||||
@@ -75,10 +68,7 @@ from test.test_utils import mock_detections
|
||||
[
|
||||
DetectionDataset(
|
||||
classes=["dog", "person"],
|
||||
images={
|
||||
"image-1.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
"image-2.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
},
|
||||
images=["image-1.png", "image-2.png"],
|
||||
annotations={
|
||||
"image-1.png": mock_detections(
|
||||
xyxy=[[0, 0, 10, 10]], class_id=[0]
|
||||
@@ -88,14 +78,11 @@ from test.test_utils import mock_detections
|
||||
),
|
||||
},
|
||||
),
|
||||
DetectionDataset(classes=["cat"], images={}, annotations={}),
|
||||
DetectionDataset(classes=["cat"], images=[], annotations={}),
|
||||
],
|
||||
DetectionDataset(
|
||||
classes=["cat", "dog", "person"],
|
||||
images={
|
||||
"image-1.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
"image-2.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
},
|
||||
images=["image-1.png", "image-2.png"],
|
||||
annotations={
|
||||
"image-1.png": mock_detections(xyxy=[[0, 0, 10, 10]], class_id=[1]),
|
||||
"image-2.png": mock_detections(xyxy=[[0, 0, 10, 10]], class_id=[2]),
|
||||
@@ -107,10 +94,7 @@ from test.test_utils import mock_detections
|
||||
[
|
||||
DetectionDataset(
|
||||
classes=["dog", "person"],
|
||||
images={
|
||||
"image-1.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
"image-2.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
},
|
||||
images=["image-1.png", "image-2.png"],
|
||||
annotations={
|
||||
"image-1.png": mock_detections(
|
||||
xyxy=[[0, 0, 10, 10]], class_id=[0]
|
||||
@@ -122,9 +106,7 @@ from test.test_utils import mock_detections
|
||||
),
|
||||
DetectionDataset(
|
||||
classes=["cat"],
|
||||
images={
|
||||
"image-3.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
},
|
||||
images=["image-3.png"],
|
||||
annotations={
|
||||
"image-3.png": mock_detections(
|
||||
xyxy=[[0, 0, 10, 10]], class_id=[0]
|
||||
@@ -134,11 +116,7 @@ from test.test_utils import mock_detections
|
||||
],
|
||||
DetectionDataset(
|
||||
classes=["cat", "dog", "person"],
|
||||
images={
|
||||
"image-1.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
"image-2.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
"image-3.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
},
|
||||
images=["image-1.png", "image-2.png", "image-3.png"],
|
||||
annotations={
|
||||
"image-1.png": mock_detections(xyxy=[[0, 0, 10, 10]], class_id=[1]),
|
||||
"image-2.png": mock_detections(xyxy=[[0, 0, 10, 10]], class_id=[2]),
|
||||
@@ -151,10 +129,7 @@ from test.test_utils import mock_detections
|
||||
[
|
||||
DetectionDataset(
|
||||
classes=["dog", "person"],
|
||||
images={
|
||||
"image-1.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
"image-2.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
},
|
||||
images=["image-1.png", "image-2.png"],
|
||||
annotations={
|
||||
"image-1.png": mock_detections(
|
||||
xyxy=[[0, 0, 10, 10]], class_id=[0]
|
||||
@@ -166,10 +141,7 @@ from test.test_utils import mock_detections
|
||||
),
|
||||
DetectionDataset(
|
||||
classes=["dog", "person"],
|
||||
images={
|
||||
"image-2.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
"image-3.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
},
|
||||
images=["image-2.png", "image-3.png"],
|
||||
annotations={
|
||||
"image-2.png": mock_detections(
|
||||
xyxy=[[0, 0, 10, 10]], class_id=[0]
|
||||
|
||||
@@ -26,7 +26,6 @@ DETECTIONS = mock_detections(
|
||||
)
|
||||
|
||||
POLYGON = np.array([[100, 100], [200, 100], [200, 200], [100, 200]])
|
||||
FRAME_RESOLUTION = (300, 300)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -36,7 +35,6 @@ FRAME_RESOLUTION = (300, 300)
|
||||
DETECTIONS,
|
||||
sv.PolygonZone(
|
||||
POLYGON,
|
||||
FRAME_RESOLUTION,
|
||||
triggering_anchors=(
|
||||
sv.Position.TOP_LEFT,
|
||||
sv.Position.TOP_RIGHT,
|
||||
@@ -53,7 +51,6 @@ FRAME_RESOLUTION = (300, 300)
|
||||
DETECTIONS,
|
||||
sv.PolygonZone(
|
||||
POLYGON,
|
||||
FRAME_RESOLUTION,
|
||||
),
|
||||
np.array(
|
||||
[False, False, True, True, True, True, False, False, False], dtype=bool
|
||||
@@ -64,7 +61,6 @@ FRAME_RESOLUTION = (300, 300)
|
||||
DETECTIONS,
|
||||
sv.PolygonZone(
|
||||
POLYGON,
|
||||
FRAME_RESOLUTION,
|
||||
triggering_anchors=[sv.Position.BOTTOM_CENTER],
|
||||
),
|
||||
np.array(
|
||||
@@ -76,7 +72,6 @@ FRAME_RESOLUTION = (300, 300)
|
||||
sv.Detections.empty(),
|
||||
sv.PolygonZone(
|
||||
POLYGON,
|
||||
FRAME_RESOLUTION,
|
||||
),
|
||||
np.array([], dtype=bool),
|
||||
DoesNotRaise(),
|
||||
@@ -107,4 +102,4 @@ def test_polygon_zone_trigger(
|
||||
)
|
||||
def test_polygon_zone_initialization(polygon, triggering_anchors, exception):
|
||||
with exception:
|
||||
sv.PolygonZone(polygon, FRAME_RESOLUTION, triggering_anchors=triggering_anchors)
|
||||
sv.PolygonZone(polygon, triggering_anchors=triggering_anchors)
|
||||
|
||||
Reference in New Issue
Block a user