Skip to content

Commit

Permalink
fix #7666
Browse files Browse the repository at this point in the history
Signed-off-by: YunLiu <[email protected]>
  • Loading branch information
KumoLiu committed Apr 18, 2024
1 parent 91ab6ff commit decf830
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion tests/test_clip_intensity_percentiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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])
Expand Down
3 changes: 2 additions & 1 deletion tests/test_clip_intensity_percentilesd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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])
Expand Down

0 comments on commit decf830

Please sign in to comment.