From decf83023460afbf80f2f99cefdbe41269dbfbdc Mon Sep 17 00:00:00 2001 From: YunLiu <55491388+KumoLiu@users.noreply.github.com> Date: Thu, 18 Apr 2024 22:49:33 +0800 Subject: [PATCH] fix #7666 Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> --- tests/test_clip_intensity_percentiles.py | 3 ++- tests/test_clip_intensity_percentilesd.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_clip_intensity_percentiles.py b/tests/test_clip_intensity_percentiles.py index 82471e25ce..f584a0bb41 100644 --- a/tests/test_clip_intensity_percentiles.py +++ b/tests/test_clip_intensity_percentiles.py @@ -18,6 +18,7 @@ from monai.transforms import ClipIntensityPercentiles from monai.transforms.utils import soft_clip from monai.transforms.utils_pytorch_numpy_unification import clip, percentile +from monai.utils.type_conversion import convert_to_tensor from tests.utils import TEST_NDARRAYS, NumpyImageTestCase2D, NumpyImageTestCase3D, assert_allclose @@ -29,7 +30,7 @@ def test_hard_clipping_two_sided(self, p): im = p(self.imt) result = hard_clipper(im) lower, upper = percentile(im, (5, 95)) - expected = clip(im, lower, upper) + expected = clip(convert_to_tensor(im), lower, upper) assert_allclose(result, p(expected), type_test="tensor", rtol=1e-7, atol=0) @parameterized.expand([[p] for p in TEST_NDARRAYS]) diff --git a/tests/test_clip_intensity_percentilesd.py b/tests/test_clip_intensity_percentilesd.py index 2b49383182..97c08f9f4e 100644 --- a/tests/test_clip_intensity_percentilesd.py +++ b/tests/test_clip_intensity_percentilesd.py @@ -19,6 +19,7 @@ from monai.transforms import ClipIntensityPercentilesd from monai.transforms.utils import soft_clip from monai.transforms.utils_pytorch_numpy_unification import clip, percentile +from monai.utils.type_conversion import convert_to_tensor from tests.utils import TEST_NDARRAYS, NumpyImageTestCase2D, NumpyImageTestCase3D, assert_allclose @@ -31,7 +32,7 @@ def test_hard_clipping_two_sided(self, p): im = p(self.imt) result = hard_clipper({key: im}) lower, upper = percentile(im, (5, 95)) - expected = clip(im, lower, upper) + expected = clip(convert_to_tensor(im), lower, upper) assert_allclose(result[key], p(expected), type_test="tensor", rtol=1e-7, atol=0) @parameterized.expand([[p] for p in TEST_NDARRAYS])