Skip to content

Commit 0735dfd

Browse files
committed
Refactor test_meta_tensor to use dict_product for parameter combinations
Signed-off-by: R. Garcia-Dias <[email protected]>
1 parent b2ccb26 commit 0735dfd

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tests/data/meta_tensor/test_meta_tensor.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,17 @@
3232
from monai.data.utils import decollate_batch, list_data_collate
3333
from monai.transforms import BorderPadd, Compose, DivisiblePadd, FromMetaTensord, ToMetaTensord
3434
from monai.utils.enums import PostFix
35-
from tests.test_utils import TEST_DEVICES, SkipIfBeforePyTorchVersion, assert_allclose, skip_if_no_cuda
35+
from tests.test_utils import TEST_DEVICES, SkipIfBeforePyTorchVersion, assert_allclose, dict_product, skip_if_no_cuda
3636

3737
DTYPES = [[torch.float32], [torch.float64], [torch.float16], [torch.int64], [torch.int32], [None]]
38+
39+
# Replace nested loops with dict_product
3840
TESTS = []
39-
for _device in TEST_DEVICES:
40-
for _dtype in DTYPES:
41-
TESTS.append((*_device, *_dtype)) # type: ignore
41+
for params in dict_product(
42+
device=TEST_DEVICES,
43+
dtype=DTYPES
44+
):
45+
TESTS.append((*params["device"], *params["dtype"])) # type: ignore
4246

4347

4448
def rand_string(min_len=5, max_len=10):

0 commit comments

Comments
 (0)