Skip to content

Commit c9b41af

Browse files
committed
Refactor TEST_CASE_RESBLOCK to use dict_product for cleaner test case generation
Signed-off-by: R. Garcia-Dias <[email protected]>
1 parent e5b5895 commit c9b41af

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

tests/networks/blocks/test_segresnet_block.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,26 @@
1818

1919
from monai.networks import eval_mode
2020
from monai.networks.blocks.segresnet_block import ResBlock
21-
22-
TEST_CASE_RESBLOCK = []
23-
for spatial_dims in range(2, 4):
24-
for in_channels in range(1, 4):
25-
for kernel_size in [1, 3]:
26-
for norm in [("group", {"num_groups": 1}), "batch", "instance"]:
27-
test_case = [
28-
{
29-
"spatial_dims": spatial_dims,
30-
"in_channels": in_channels,
31-
"kernel_size": kernel_size,
32-
"norm": norm,
33-
},
34-
(2, in_channels, *([16] * spatial_dims)),
35-
(2, in_channels, *([16] * spatial_dims)),
36-
]
37-
TEST_CASE_RESBLOCK.append(test_case)
21+
from tests.test_utils import dict_product
22+
23+
TEST_CASE_RESBLOCK = [
24+
[
25+
{
26+
"spatial_dims": params["spatial_dims"],
27+
"in_channels": params["in_channels"],
28+
"kernel_size": params["kernel_size"],
29+
"norm": params["norm"],
30+
},
31+
(2, params["in_channels"], *([16] * params["spatial_dims"])),
32+
(2, params["in_channels"], *([16] * params["spatial_dims"])),
33+
]
34+
for params in dict_product(
35+
spatial_dims=range(2, 4),
36+
in_channels=range(1, 4),
37+
kernel_size=[1, 3],
38+
norm=[("group", {"num_groups": 1}), "batch", "instance"],
39+
)
40+
]
3841

3942

4043
class TestResBlock(unittest.TestCase):

0 commit comments

Comments
 (0)