Skip to content

Commit 737bbbd

Browse files
committed
tests: remove byte-identical duplicate test cases
Signed-off-by: Soumya Snigdha Kundu <soumya_snigdha.kundu@kcl.ac.uk>
1 parent 8690ae7 commit 737bbbd

7 files changed

Lines changed: 3 additions & 48 deletions

File tree

tests/fl/monai_algo/test_fl_monai_algo.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,6 @@
5353
"config_filters_filename": None,
5454
}
5555
]
56-
TEST_TRAIN_3 = [
57-
{
58-
"bundle_root": _data_dir,
59-
"train_workflow": ConfigWorkflow(
60-
config_file=os.path.join(_data_dir, "config_fl_train.json"),
61-
workflow_type="train",
62-
logging_file=_logging_file,
63-
),
64-
"config_evaluate_filename": None,
65-
"config_filters_filename": os.path.join(_data_dir, "config_fl_filters.json"),
66-
}
67-
]
6856

6957
TEST_TRAIN_4 = [
7058
{
@@ -182,7 +170,7 @@
182170
@SkipIfNoModule("ignite")
183171
@SkipIfNoModule("mlflow")
184172
class TestFLMonaiAlgo(unittest.TestCase):
185-
@parameterized.expand([TEST_TRAIN_1, TEST_TRAIN_2, TEST_TRAIN_3, TEST_TRAIN_4])
173+
@parameterized.expand([TEST_TRAIN_1, TEST_TRAIN_2, TEST_TRAIN_4])
186174
def test_train(self, input_params):
187175
# initialize algo
188176
algo = MonaiAlgo(**input_params)

tests/inferers/test_patch_inferer.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -231,17 +231,6 @@
231231
TEST_CASE_ERROR_8 = [torch.zeros(2, 2), dict(splitter=None), ValueError]
232232
# invalid inputs: split patches MetaTensor without location metadata
233233
TEST_CASE_ERROR_9 = [MetaTensor(torch.zeros(2, 2)), dict(splitter=None), ValueError]
234-
# merged_shape is not provided for the merger
235-
TEST_CASE_ERROR_10 = [
236-
[
237-
(TENSOR_4x4[..., :2, :2], (0, 0)),
238-
(TENSOR_4x4[..., :2, 2:], (0, 2)),
239-
(TENSOR_4x4[..., 2:, :2], (2, 0)),
240-
(TENSOR_4x4[..., 2:, 2:], (2, 2)),
241-
],
242-
dict(splitter=SlidingWindowSplitter(patch_size=(2, 2))),
243-
ValueError,
244-
]
245234

246235

247236
class PatchInfererTests(unittest.TestCase):

tests/transforms/spatial/test_grid_patch.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
TEST_CASE_1 = [{"patch_size": (2, 2), "num_patches": 3}, A, [A11, A12, A21]]
3232
TEST_CASE_2 = [{"patch_size": (2, 2), "num_patches": 5}, A, [A11, A12, A21, A22, np.zeros((3, 2, 2))]]
3333
TEST_CASE_3 = [{"patch_size": (2, 2), "offset": (0, 0)}, A, [A11, A12, A21, A22]]
34-
TEST_CASE_4 = [{"patch_size": (2, 2), "offset": (0, 0)}, A, [A11, A12, A21, A22]]
3534
TEST_CASE_5 = [{"patch_size": (2, 2), "offset": (2, 2)}, A, [A22]]
3635
TEST_CASE_6 = [{"patch_size": (2, 2), "offset": (0, 2)}, A, [A12, A22]]
3736
TEST_CASE_7 = [{"patch_size": (2, 2), "offset": (2, 0)}, A, [A21, A22]]
@@ -81,7 +80,6 @@
8180
TEST_CASES.append([p, *TEST_CASE_1])
8281
TEST_CASES.append([p, *TEST_CASE_2])
8382
TEST_CASES.append([p, *TEST_CASE_3])
84-
TEST_CASES.append([p, *TEST_CASE_4])
8583
TEST_CASES.append([p, *TEST_CASE_5])
8684
TEST_CASES.append([p, *TEST_CASE_6])
8785
TEST_CASES.append([p, *TEST_CASE_7])

tests/transforms/spatial/test_grid_patchd.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
TEST_CASE_1 = [{"patch_size": (2, 2), "num_patches": 3}, {"image": A}, [A11, A12, A21]]
3131
TEST_CASE_2 = [{"patch_size": (2, 2), "num_patches": 5}, {"image": A}, [A11, A12, A21, A22, np.zeros((3, 2, 2))]]
3232
TEST_CASE_3 = [{"patch_size": (2, 2), "offset": (0, 0)}, {"image": A}, [A11, A12, A21, A22]]
33-
TEST_CASE_4 = [{"patch_size": (2, 2), "offset": (0, 0)}, {"image": A}, [A11, A12, A21, A22]]
3433
TEST_CASE_5 = [{"patch_size": (2, 2), "offset": (2, 2)}, {"image": A}, [A22]]
3534
TEST_CASE_6 = [{"patch_size": (2, 2), "offset": (0, 2)}, {"image": A}, [A12, A22]]
3635
TEST_CASE_7 = [{"patch_size": (2, 2), "offset": (2, 0)}, {"image": A}, [A21, A22]]
@@ -61,7 +60,6 @@
6160
TEST_SINGLE.append([p, *TEST_CASE_1])
6261
TEST_SINGLE.append([p, *TEST_CASE_2])
6362
TEST_SINGLE.append([p, *TEST_CASE_3])
64-
TEST_SINGLE.append([p, *TEST_CASE_4])
6563
TEST_SINGLE.append([p, *TEST_CASE_5])
6664
TEST_SINGLE.append([p, *TEST_CASE_6])
6765
TEST_SINGLE.append([p, *TEST_CASE_7])

tests/transforms/spatial/test_rand_grid_patch.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
A,
3636
[A11, A12, A21, A22, np.zeros((3, 2, 2))],
3737
]
38-
TEST_CASE_3 = [{"patch_size": (2, 2), "min_offset": 0, "max_offset": 0}, A, [A11, A12, A21, A22]]
3938
TEST_CASE_4 = [{"patch_size": (2, 2)}, A, [A11, A12, A21, A22]]
4039
TEST_CASE_5 = [{"patch_size": (2, 2), "min_offset": 2, "max_offset": 2}, A, [A22]]
4140
TEST_CASE_6 = [{"patch_size": (2, 2), "min_offset": (0, 2), "max_offset": (0, 2)}, A, [A12, A22]]
@@ -91,7 +90,6 @@
9190
TEST_SINGLE.append([p, *TEST_CASE_0])
9291
TEST_SINGLE.append([p, *TEST_CASE_1])
9392
TEST_SINGLE.append([p, *TEST_CASE_2])
94-
TEST_SINGLE.append([p, *TEST_CASE_3])
9593
TEST_SINGLE.append([p, *TEST_CASE_4])
9694
TEST_SINGLE.append([p, *TEST_CASE_5])
9795
TEST_SINGLE.append([p, *TEST_CASE_6])

tests/transforms/spatial/test_rand_grid_patchd.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
{"image": A},
3535
[A11, A12, A21, A22, np.zeros((3, 2, 2))],
3636
]
37-
TEST_CASE_3 = [{"patch_size": (2, 2), "min_offset": 0, "max_offset": 0}, {"image": A}, [A11, A12, A21, A22]]
3837
TEST_CASE_4 = [{"patch_size": (2, 2)}, {"image": A}, [A11, A12, A21, A22]]
3938
TEST_CASE_5 = [{"patch_size": (2, 2), "min_offset": 2, "max_offset": 2}, {"image": A}, [A22]]
4039
TEST_CASE_6 = [{"patch_size": (2, 2), "min_offset": (0, 2), "max_offset": (0, 2)}, {"image": A}, [A12, A22]]
@@ -71,7 +70,6 @@
7170
TEST_SINGLE.append([p, *TEST_CASE_0])
7271
TEST_SINGLE.append([p, *TEST_CASE_1])
7372
TEST_SINGLE.append([p, *TEST_CASE_2])
74-
TEST_SINGLE.append([p, *TEST_CASE_3])
7573
TEST_SINGLE.append([p, *TEST_CASE_4])
7674
TEST_SINGLE.append([p, *TEST_CASE_5])
7775
TEST_SINGLE.append([p, *TEST_CASE_6])

tests/transforms/test_load_image.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ def get_data(self, _obj):
5454

5555
TEST_CASE_1 = [{}, ["test_image.nii.gz"], (128, 128, 128)]
5656

57-
TEST_CASE_2 = [{}, ["test_image.nii.gz"], (128, 128, 128)]
58-
5957
TEST_CASE_3 = [{}, ["test_image.nii.gz", "test_image2.nii.gz", "test_image3.nii.gz"], (3, 128, 128, 128)]
6058

6159
TEST_CASE_3_1 = [ # .mgz format
@@ -64,8 +62,6 @@ def get_data(self, _obj):
6462
(3, 128, 128, 128),
6563
]
6664

67-
TEST_CASE_4 = [{}, ["test_image.nii.gz", "test_image2.nii.gz", "test_image3.nii.gz"], (3, 128, 128, 128)]
68-
6965
TEST_CASE_4_1 = [ # additional parameter
7066
{"mmap": False},
7167
["test_image.nii.gz", "test_image2.nii.gz", "test_image3.nii.gz"],
@@ -92,8 +88,6 @@ def get_data(self, _obj):
9288

9389
TEST_CASE_6 = [{"reader": ITKReader() if has_itk else "itkreader"}, ["test_image.nii.gz"], (128, 128, 128)]
9490

95-
TEST_CASE_7 = [{"reader": ITKReader() if has_itk else "itkreader"}, ["test_image.nii.gz"], (128, 128, 128)]
96-
9791
TEST_CASE_8 = [
9892
{"reader": ITKReader() if has_itk else "itkreader"},
9993
["test_image.nii.gz", "test_image2.nii.gz", "test_image3.nii.gz"],
@@ -106,12 +100,6 @@ def get_data(self, _obj):
106100
(384, 128, 128),
107101
]
108102

109-
TEST_CASE_9 = [
110-
{"reader": ITKReader() if has_itk else "itkreader"},
111-
["test_image.nii.gz", "test_image2.nii.gz", "test_image3.nii.gz"],
112-
(3, 128, 128, 128),
113-
]
114-
115103
TEST_CASE_10 = [
116104
{"reader": ITKReader(pixel_type=itk_uc) if has_itk else "itkreader"},
117105
"tests/testing_data/CT_DICOM",
@@ -205,9 +193,7 @@ def tearDownClass(cls):
205193
shutil.rmtree(cls.tmpdir)
206194
super().tearDownClass()
207195

208-
@parameterized.expand(
209-
[TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_3_1, TEST_CASE_4, TEST_CASE_4_1, TEST_CASE_5]
210-
)
196+
@parameterized.expand([TEST_CASE_1, TEST_CASE_3, TEST_CASE_3_1, TEST_CASE_4_1, TEST_CASE_5])
211197
def test_nibabel_reader(self, input_param, filenames, expected_shape):
212198
test_image = np.random.rand(128, 128, 128)
213199
with tempfile.TemporaryDirectory() as tempdir:
@@ -249,7 +235,7 @@ def test_nibabel_reader_gpu(self, input_param, filenames, expected_shape):
249235
result_cpu = LoadImage(image_only=True, **input_param_cpu)(filenames)
250236
assert_allclose(result_cpu, result.cpu(), atol=1e-6)
251237

252-
@parameterized.expand([TEST_CASE_6, TEST_CASE_7, TEST_CASE_8, TEST_CASE_8_1, TEST_CASE_9])
238+
@parameterized.expand([TEST_CASE_6, TEST_CASE_8, TEST_CASE_8_1])
253239
def test_itk_reader(self, input_param, filenames, expected_shape):
254240
test_image = torch.randint(0, 256, (128, 128, 128), dtype=torch.uint8).numpy()
255241
print("Test image value range:", test_image.min(), test_image.max())

0 commit comments

Comments
 (0)