Skip to content

Commit ad79cdf

Browse files
committed
[DLMED] fix mypy
Signed-off-by: Nic Ma <[email protected]>
1 parent ac97a0c commit ad79cdf

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

monai/transforms/intensity/array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1688,7 +1688,7 @@ def __call__(self, img: np.ndarray):
16881688
raise ValueError("fill_value should contain 2 numbers if providing the `min` and `max`.")
16891689
img[h] = self.R.uniform(self.fill_value[0], self.fill_value[1], size=img[h].shape)
16901690
else:
1691-
img[h] = self.fill_value
1691+
img[h] = self.fill_value # type: ignore
16921692

16931693
return img
16941694

monai/transforms/intensity/dictionary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1489,7 +1489,7 @@ def __call__(self, data):
14891489
raise ValueError("fill_value should contain 2 numbers if providing the `min` and `max`.")
14901490
d[key][h] = self.R.uniform(self.fill_value[0], self.fill_value[1], size=d[key][h].shape)
14911491
else:
1492-
d[key][h] = self.fill_value
1492+
d[key][h] = self.fill_value # type: ignore
14931493
return d
14941494

14951495

tests/test_rand_coarse_dropoutd.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,14 @@
5151
{"img": np.random.randint(0, 2, size=[3, 3, 3, 4])},
5252
]
5353

54+
TEST_CASE_4 = [
55+
{"keys": "img", "holes": 2, "spatial_size": [2, 2, 2], "fill_value": (0.2, 0.6), "prob": 1.0},
56+
{"img": np.random.rand((3, 3, 3, 4))},
57+
]
58+
5459

5560
class TestRandCoarseDropoutd(unittest.TestCase):
56-
@parameterized.expand([TEST_CASE_0, TEST_CASE_1, TEST_CASE_2, TEST_CASE_3])
61+
@parameterized.expand([TEST_CASE_0, TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4])
5762
def test_value(self, input_param, input_data):
5863
dropout = RandCoarseDropoutd(**input_param)
5964
result = dropout(input_data)["img"]
@@ -74,6 +79,7 @@ def test_value(self, input_param, input_data):
7479
if isinstance(fill_value, (int, float)):
7580
np.testing.assert_allclose(data, fill_value)
7681
else:
82+
print("hole data:", data)
7783
min_value = data.min()
7884
max_value = data.max()
7985
self.assertGreaterEqual(max_value, min_value)

0 commit comments

Comments
 (0)