Skip to content

Commit 60f7201

Browse files
committed
Refactor test cases in test_spacing.py to use dict_product for cleaner test generation
Signed-off-by: R. Garcia-Dias <[email protected]>
1 parent 74741e7 commit 60f7201

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

tests/transforms/test_spacing.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -204,23 +204,20 @@
204204
torch.ones((1, 302, 403, 301)),
205205
],
206206
]
207-
208207
TESTS: list[list] = [
209208
params["template"] + [*params["device_val"]]
210209
for params in dict_product(template=all_template_parts, device_val=TEST_DEVICES)
211210
]
212211

213-
TESTS_TORCH = []
214-
for track_meta in (False, True):
215-
for p in TEST_NDARRAYS_ALL:
216-
TESTS_TORCH.append([[1.2, 1.3, 0.9], p(torch.zeros((1, 3, 4, 5))), track_meta])
212+
TESTS_TORCH = [
213+
[[1.2, 1.3, 0.9], params["p"](torch.zeros((1, 3, 4, 5))), params["track_meta"]]
214+
for params in dict_product(track_meta=[False, True], p=TEST_NDARRAYS_ALL)
215+
]
217216

218-
TEST_INVERSE = []
219-
for d in TEST_DEVICES:
220-
for recompute in (False, True):
221-
for align in (False, True):
222-
for scale_extent in (False, True):
223-
TEST_INVERSE.append([*d, recompute, align, scale_extent])
217+
TEST_INVERSE = [
218+
[*params["d"], params["recompute"], params["align"], params["scale_extent"]]
219+
for params in dict_product(d=TEST_DEVICES, recompute=[False, True], align=[False, True], scale_extent=[False, True])
220+
]
224221

225222

226223
@skip_if_quick

0 commit comments

Comments
 (0)