Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion monai/transforms/post/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class AsDiscrete(Transform):
Defaults to ``False``.
to_onehot: if not None, convert input data into the one-hot format with specified number of classes.
Defaults to ``None``.
threshold: if not None, threshold the float values to int number 0 or 1 with specified theashold.
threshold: if not None, threshold the float values to int number 0 or 1 with specified threshold.
Defaults to ``None``.
rounding: if not None, round the data according to the specified option,
available options: ["torchrounding"].
Expand Down
12 changes: 6 additions & 6 deletions tests/test_crop_foreground.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@

class TestCropForeground(unittest.TestCase):
@parameterized.expand(TEST_COORDS + TESTS)
def test_value(self, argments, image, expected_data):
cropper = CropForeground(**argments)
def test_value(self, arguments, image, expected_data):
cropper = CropForeground(**arguments)
result = cropper(image)
assert_allclose(result, expected_data, type_test=False)
self.assertIsInstance(result, MetaTensor)
Expand All @@ -100,10 +100,10 @@ def test_value(self, argments, image, expected_data):
self.assertTupleEqual(inv.shape, image.shape)

@parameterized.expand(TEST_COORDS)
def test_return_coords(self, argments, image, _):
argments["return_coords"] = True
_, start_coord, end_coord = CropForeground(**argments)(image)
argments["return_coords"] = False
def test_return_coords(self, arguments, image, _):
arguments["return_coords"] = True
_, start_coord, end_coord = CropForeground(**arguments)(image)
arguments["return_coords"] = False
np.testing.assert_allclose(start_coord, np.asarray([1, 1]))
np.testing.assert_allclose(end_coord, np.asarray([4, 4]))

Expand Down
14 changes: 7 additions & 7 deletions tests/test_crop_foregroundd.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@

class TestCropForegroundd(unittest.TestCase):
@parameterized.expand(TEST_POSITION + TESTS)
def test_value(self, argments, input_data, expected_data):
cropper = CropForegroundd(**argments)
def test_value(self, arguments, input_data, expected_data):
cropper = CropForegroundd(**arguments)
result = cropper(input_data)
assert_allclose(result["img"], expected_data, type_test="tensor")
if "label" in input_data and "img" in input_data:
Expand All @@ -161,14 +161,14 @@ def test_value(self, argments, input_data, expected_data):
self.assertTupleEqual(inv["label"].shape, input_data["label"].shape)

@parameterized.expand(TEST_POSITION)
def test_foreground_position(self, argments, input_data, _):
result = CropForegroundd(**argments)(input_data)
def test_foreground_position(self, arguments, input_data, _):
result = CropForegroundd(**arguments)(input_data)
np.testing.assert_allclose(result["foreground_start_coord"], np.array([1, 1]))
np.testing.assert_allclose(result["foreground_end_coord"], np.array([4, 4]))

argments["start_coord_key"] = "test_start_coord"
argments["end_coord_key"] = "test_end_coord"
result = CropForegroundd(**argments)(input_data)
arguments["start_coord_key"] = "test_start_coord"
arguments["end_coord_key"] = "test_end_coord"
result = CropForegroundd(**arguments)(input_data)
np.testing.assert_allclose(result["test_start_coord"], np.array([1, 1]))
np.testing.assert_allclose(result["test_end_coord"], np.array([4, 4]))

Expand Down
4 changes: 2 additions & 2 deletions tests/test_gaussian_sharpen.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@

class TestGaussianSharpen(unittest.TestCase):
@parameterized.expand(TESTS)
def test_value(self, argments, image, expected_data):
result = GaussianSharpen(**argments)(image)
def test_value(self, arguments, image, expected_data):
result = GaussianSharpen(**arguments)(image)
assert_allclose(result, expected_data, atol=0, rtol=1e-4, type_test="tensor")


Expand Down
4 changes: 2 additions & 2 deletions tests/test_gaussian_sharpend.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@

class TestGaussianSharpend(unittest.TestCase):
@parameterized.expand(TESTS)
def test_value(self, argments, image, expected_data):
result = GaussianSharpend(**argments)(image)
def test_value(self, arguments, image, expected_data):
result = GaussianSharpend(**arguments)(image)
assert_allclose(result["img"], expected_data, rtol=1e-4, type_test="tensor")


Expand Down
4 changes: 2 additions & 2 deletions tests/test_gaussian_smooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@

class TestGaussianSmooth(unittest.TestCase):
@parameterized.expand(TESTS)
def test_value(self, argments, image, expected_data):
result = GaussianSmooth(**argments)(image)
def test_value(self, arguments, image, expected_data):
result = GaussianSmooth(**arguments)(image)
assert_allclose(result, expected_data, atol=1e-4, rtol=1e-4, type_test="tensor")


Expand Down
4 changes: 2 additions & 2 deletions tests/test_gaussian_smoothd.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@

class TestGaussianSmoothd(unittest.TestCase):
@parameterized.expand(TESTS)
def test_value(self, argments, image, expected_data):
result = GaussianSmoothd(**argments)(image)
def test_value(self, arguments, image, expected_data):
result = GaussianSmoothd(**arguments)(image)
assert_allclose(result["img"], expected_data, rtol=1e-4, type_test="tensor")


Expand Down
8 changes: 4 additions & 4 deletions tests/test_generate_distance_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@

class TestGenerateDistanceMap(unittest.TestCase):
@parameterized.expand(EXCEPTION_TESTS)
def test_value(self, argments, mask, probmap, exception_type):
def test_value(self, arguments, mask, probmap, exception_type):
with self.assertRaises(exception_type):
GenerateDistanceMap(**argments)(mask, probmap)
GenerateDistanceMap(**arguments)(mask, probmap)

@parameterized.expand(TESTS)
def test_value2(self, argments, mask, probmap, expected_shape):
result = GenerateDistanceMap(**argments)(mask, probmap)
def test_value2(self, arguments, mask, probmap, expected_shape):
result = GenerateDistanceMap(**arguments)(mask, probmap)
self.assertEqual(result.shape, expected_shape)


Expand Down
8 changes: 4 additions & 4 deletions tests/test_generate_distance_mapd.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@

class TestGenerateDistanceMapd(unittest.TestCase):
@parameterized.expand(EXCEPTION_TESTS)
def test_value(self, argments, mask, border_map, exception_type):
def test_value(self, arguments, mask, border_map, exception_type):
with self.assertRaises(exception_type):
GenerateDistanceMapd(**argments)({"mask": mask, "border": border_map})
GenerateDistanceMapd(**arguments)({"mask": mask, "border": border_map})

@parameterized.expand(TESTS)
def test_value2(self, argments, mask, border_map, expected_shape):
result = GenerateDistanceMapd(**argments)({"mask": mask, "border": border_map})
def test_value2(self, arguments, mask, border_map, expected_shape):
result = GenerateDistanceMapd(**arguments)({"mask": mask, "border": border_map})
self.assertEqual(result["dist_map"].shape, expected_shape)


Expand Down
8 changes: 4 additions & 4 deletions tests/test_generate_instance_borderd.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@

class TestGenerateInstanceBorderd(unittest.TestCase):
@parameterized.expand(EXCEPTION_TESTS)
def test_value(self, argments, mask, hover_map, exception_type):
def test_value(self, arguments, mask, hover_map, exception_type):
with self.assertRaises(exception_type):
GenerateInstanceBorderd(**argments)({"mask": mask, "hover_map": hover_map})
GenerateInstanceBorderd(**arguments)({"mask": mask, "hover_map": hover_map})

@parameterized.expand(TESTS)
def test_value2(self, argments, mask, hover_map, expected_shape):
result = GenerateInstanceBorderd(**argments)({"mask": mask, "hover_map": hover_map})
def test_value2(self, arguments, mask, hover_map, expected_shape):
result = GenerateInstanceBorderd(**arguments)({"mask": mask, "hover_map": hover_map})
self.assertEqual(result["border"].shape, expected_shape)


Expand Down
8 changes: 4 additions & 4 deletions tests/test_generate_watershed_maskd.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@
@unittest.skipUnless(has_scipy, "Requires scipy library.")
class TestGenerateWatershedMaskd(unittest.TestCase):
@parameterized.expand(EXCEPTION_TESTS)
def test_value(self, argments, exception_type):
def test_value(self, arguments, exception_type):
with self.assertRaises(exception_type):
GenerateWatershedMaskd(**argments)
GenerateWatershedMaskd(**arguments)

@parameterized.expand(TESTS)
def test_value2(self, argments, image, expected_shape, expected_value):
result = GenerateWatershedMaskd(**argments)({"img": image})
def test_value2(self, arguments, image, expected_shape, expected_value):
result = GenerateWatershedMaskd(**arguments)({"img": image})
self.assertEqual(result["mask"].shape, expected_shape)

if isinstance(result["mask"], torch.Tensor):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_histogram_normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@

class TestHistogramNormalize(unittest.TestCase):
@parameterized.expand(TESTS)
def test_value(self, argments, image, expected_data):
result = HistogramNormalize(**argments)(image)
def test_value(self, arguments, image, expected_data):
result = HistogramNormalize(**arguments)(image)
assert_allclose(result, expected_data, type_test="tensor")
self.assertEqual(get_equivalent_dtype(result.dtype, data_type=np.ndarray), argments.get("dtype", np.float32))
self.assertEqual(get_equivalent_dtype(result.dtype, data_type=np.ndarray), arguments.get("dtype", np.float32))


if __name__ == "__main__":
Expand Down
6 changes: 3 additions & 3 deletions tests/test_histogram_normalized.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@

class TestHistogramNormalized(unittest.TestCase):
@parameterized.expand(TESTS)
def test_value(self, argments, image, expected_data):
result = HistogramNormalized(**argments)(image)["img"]
def test_value(self, arguments, image, expected_data):
result = HistogramNormalized(**arguments)(image)["img"]
assert_allclose(result, expected_data, type_test="tensor")
self.assertEqual(get_equivalent_dtype(result.dtype, data_type=np.ndarray), argments.get("dtype", np.float32))
self.assertEqual(get_equivalent_dtype(result.dtype, data_type=np.ndarray), arguments.get("dtype", np.float32))


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions tests/test_label_to_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@

class TestLabelToMask(unittest.TestCase):
@parameterized.expand(TESTS)
def test_value(self, argments, image, expected_data):
result = LabelToMask(**argments)(image)
def test_value(self, arguments, image, expected_data):
result = LabelToMask(**arguments)(image)
assert_allclose(result, expected_data, type_test="tensor")


Expand Down
4 changes: 2 additions & 2 deletions tests/test_label_to_maskd.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@

class TestLabelToMaskd(unittest.TestCase):
@parameterized.expand(TESTS)
def test_value(self, argments, input_data, expected_data):
result = LabelToMaskd(**argments)(input_data)
def test_value(self, arguments, input_data, expected_data):
result = LabelToMaskd(**arguments)(input_data)
r = result["img"]
assert_allclose(r, expected_data, type_test="tensor")

Expand Down
4 changes: 2 additions & 2 deletions tests/test_mask_intensity.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@

class TestMaskIntensity(unittest.TestCase):
@parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4, TEST_CASE_5])
def test_value(self, argments, image, expected_data):
def test_value(self, arguments, image, expected_data):
for p in TEST_NDARRAYS:
result = MaskIntensity(**argments)(p(image))
result = MaskIntensity(**arguments)(p(image))
assert_allclose(result, p(expected_data), type_test="tensor")

def test_runtime_mask(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_mask_intensityd.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@

class TestMaskIntensityd(unittest.TestCase):
@parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4, TEST_CASE_5])
def test_value(self, argments, image, expected_data):
result = MaskIntensityd(**argments)(image)
def test_value(self, arguments, image, expected_data):
result = MaskIntensityd(**arguments)(image)
np.testing.assert_allclose(result["img"], expected_data)


Expand Down
4 changes: 2 additions & 2 deletions tests/test_median_smooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@

class TestMedianSmooth(unittest.TestCase):
@parameterized.expand(TESTS)
def test_value(self, argments, image, expected_data):
result = MedianSmooth(**argments)(image)
def test_value(self, arguments, image, expected_data):
result = MedianSmooth(**arguments)(image)
assert_allclose(result, expected_data, atol=1e-4, rtol=1e-4, type_test="tensor")


Expand Down
4 changes: 2 additions & 2 deletions tests/test_pathology_he_stain.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def test_transparent_image(self, image):
NORMALIZE_STAINS_TEST_CASE_4,
]
)
def test_result_value(self, argments, image, expected_data):
def test_result_value(self, arguments, image, expected_data):
"""
Test that an input image returns an expected normalized image.

Expand Down Expand Up @@ -218,7 +218,7 @@ def test_result_value(self, argments, image, expected_data):
with self.assertRaises(TypeError):
NormalizeHEStains()(image)
else:
result = NormalizeHEStains(**argments)(image)
result = NormalizeHEStains(**arguments)(image)
np.testing.assert_allclose(result, expected_data)


Expand Down
4 changes: 2 additions & 2 deletions tests/test_pathology_he_stain_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def test_transparent_image(self, image):
NORMALIZE_STAINS_TEST_CASE_4,
]
)
def test_result_value(self, argments, image, expected_data):
def test_result_value(self, arguments, image, expected_data):
"""
Test that an input image returns an expected normalized image.

Expand Down Expand Up @@ -213,7 +213,7 @@ def test_result_value(self, argments, image, expected_data):
with self.assertRaises(TypeError):
NormalizeHEStainsD([key])({key: image})
else:
result = NormalizeHEStainsD([key], **argments)({key: image})
result = NormalizeHEStainsD([key], **arguments)({key: image})
np.testing.assert_allclose(result[key], expected_data)


Expand Down
4 changes: 2 additions & 2 deletions tests/test_rand_gaussian_sharpen.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@

class TestRandGaussianSharpen(unittest.TestCase):
@parameterized.expand(TESTS)
def test_value(self, argments, image, expected_data):
converter = RandGaussianSharpen(**argments)
def test_value(self, arguments, image, expected_data):
converter = RandGaussianSharpen(**arguments)
converter.set_random_state(seed=0)
result = converter(image)
assert_allclose(result, expected_data, atol=0, rtol=1e-4, type_test="tensor")
Expand Down
4 changes: 2 additions & 2 deletions tests/test_rand_gaussian_sharpend.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@

class TestRandGaussianSharpend(unittest.TestCase):
@parameterized.expand(TESTS)
def test_value(self, argments, image, expected_data):
converter = RandGaussianSharpend(**argments)
def test_value(self, arguments, image, expected_data):
converter = RandGaussianSharpend(**arguments)
converter.set_random_state(seed=0)
result = converter(image)
assert_allclose(result["img"], expected_data, rtol=1e-4, type_test=False)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_rand_gaussian_smooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@

class TestRandGaussianSmooth(unittest.TestCase):
@parameterized.expand(TESTS)
def test_value(self, argments, image, expected_data):
converter = RandGaussianSmooth(**argments)
def test_value(self, arguments, image, expected_data):
converter = RandGaussianSmooth(**arguments)
converter.set_random_state(seed=0)
result = converter(image)
assert_allclose(result, expected_data, rtol=1e-4, type_test="tensor")
Expand Down
4 changes: 2 additions & 2 deletions tests/test_rand_gaussian_smoothd.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@

class TestRandGaussianSmoothd(unittest.TestCase):
@parameterized.expand(TESTS)
def test_value(self, argments, image, expected_data):
converter = RandGaussianSmoothd(**argments)
def test_value(self, arguments, image, expected_data):
converter = RandGaussianSmoothd(**arguments)
converter.set_random_state(seed=0)
result = converter(image)
assert_allclose(result["img"], expected_data, rtol=1e-4, type_test=False)
Expand Down