Skip to content

Commit a5596d7

Browse files
committed
revert change to tests/apps/detection/test_box_transform.py
Signed-off-by: R. Garcia-Dias <[email protected]>
1 parent c06cad1 commit a5596d7

File tree

1 file changed

+21
-32
lines changed

1 file changed

+21
-32
lines changed

tests/apps/detection/test_box_transform.py

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,20 @@
3636
)
3737
from monai.data.meta_tensor import MetaTensor
3838
from monai.transforms import CastToTyped, Invertd
39-
from tests.test_utils import TEST_NDARRAYS, assert_allclose, dict_product
39+
from tests.test_utils import TEST_NDARRAYS, assert_allclose
4040

41-
# Define common test data
42-
boxes_3d = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 2, 3, 3], [0, 1, 1, 2, 3, 4]]
43-
labels_3d = [1, 1, 0]
44-
scores_3d = [[0.2, 0.8], [0.3, 0.7], [0.6, 0.4]]
45-
image_size_3d = [1, 4, 6, 4]
46-
image_3d = np.zeros(image_size_3d)
47-
48-
# Use dict_product for TESTS_3D
4941
TESTS_3D = []
50-
for params in dict_product(ndarray_type=TEST_NDARRAYS):
51-
p = params["ndarray_type"]
42+
boxes = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 2, 3, 3], [0, 1, 1, 2, 3, 4]]
43+
labels = [1, 1, 0]
44+
scores = [[0.2, 0.8], [0.3, 0.7], [0.6, 0.4]]
45+
image_size = [1, 4, 6, 4]
46+
image = np.zeros(image_size)
47+
48+
for p in TEST_NDARRAYS:
5249
TESTS_3D.append(
5350
[
5451
{"box_keys": "boxes", "dst_mode": "xyzwhd"},
55-
{"boxes": p(boxes_3d), "image": p(image_3d), "labels": p(labels_3d), "scores": p(scores_3d)},
52+
{"boxes": p(boxes), "image": p(image), "labels": p(labels), "scores": p(scores)},
5653
p([[0, 0, 0, 0, 0, 0], [0, 1, 0, 2, 2, 3], [0, 1, 1, 2, 2, 3]]),
5754
p([[0, 0, 0, 0, 0, 0], [0, 3, 0, 1, 9, 4.5], [0, 3, 1.5, 1, 9, 6]]),
5855
p([[1, -6, -1, 1, -6, -1], [1, -3, -1, 2, 3, 3.5], [1, -3, 0.5, 2, 3, 5]]),
@@ -62,31 +59,23 @@
6259
]
6360
)
6461

65-
# 2D test data
66-
boxes_2d = [[0, 1, 2, 2], [0, 0, 1, 1]]
67-
labels_2d = [1, 0]
68-
image_size_2d = [1, 2, 2]
69-
image_2d = np.zeros(image_size_2d)
70-
71-
# Use dict_product for TESTS_2D
7262
TESTS_2D = []
73-
for params in dict_product(ndarray_type=TEST_NDARRAYS):
74-
p = params["ndarray_type"]
63+
boxes = [[0, 1, 2, 2], [0, 0, 1, 1]]
64+
labels = [1, 0]
65+
image_size = [1, 2, 2]
66+
image = np.zeros(image_size)
67+
for p in TEST_NDARRAYS:
7568
TESTS_2D.append(
76-
[{"boxes": p(boxes_2d), "image": p(image_2d), "labels": p(labels_2d)}, p([[[0, 2], [0, 2]], [[1, 0], [0, 0]]])]
69+
[{"boxes": p(boxes), "image": p(image), "labels": p(labels)}, p([[[0, 2], [0, 2]], [[1, 0], [0, 0]]])]
7770
)
7871

79-
# Use dict_product for TESTS_2D_mask
8072
TESTS_2D_mask = []
81-
boxes_mask_1 = [[[-1, 0], [0, -1]]]
82-
for params in dict_product(ndarray_type=TEST_NDARRAYS):
83-
p = params["ndarray_type"]
84-
TESTS_2D_mask.append([p(boxes_mask_1), (p([[0.0, 0.0, 2.0, 2.0]]), p([0]))])
85-
86-
boxes_mask_2 = [[[-1, 0], [0, -1]], [[-1, 1], [1, -1]]]
87-
for params in dict_product(ndarray_type=TEST_NDARRAYS):
88-
p = params["ndarray_type"]
89-
TESTS_2D_mask.append([p(boxes_mask_2), (p([[0.0, 0.0, 2.0, 2.0], [0.0, 0.0, 2.0, 2.0]]), p([0, 1]))])
73+
boxes_mask = [[[-1, 0], [0, -1]]]
74+
for p in TEST_NDARRAYS:
75+
TESTS_2D_mask.append([p(boxes_mask), (p([[0.0, 0.0, 2.0, 2.0]]), p([0]))])
76+
boxes_mask = [[[-1, 0], [0, -1]], [[-1, 1], [1, -1]]]
77+
for p in TEST_NDARRAYS:
78+
TESTS_2D_mask.append([p(boxes_mask), (p([[0.0, 0.0, 2.0, 2.0], [0.0, 0.0, 2.0, 2.0]]), p([0, 1]))])
9079

9180

9281
class TestBoxTransform(unittest.TestCase):

0 commit comments

Comments
 (0)