Skip to content

Commit

Permalink
Add failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
fepegar committed Oct 24, 2023
1 parent 8a08875 commit 7a1f109
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/transforms/preprocessing/test_rescale.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,18 @@ def test_invert_rescaling(self):
assert transformed.t1.data.max() == 1
inverted = transformed.apply_inverse_transform()
self.assert_tensor_almost_equal(inverted.t1.data, data)

def test_persistent_in_min_max(self):
# see https://github.com/fepegar/torchio/issues/1115
img1 = torch.tensor([[[[0, 1]]]])
img2 = torch.tensor([[[[0, 10]]]])

rescale = tio.RescaleIntensity(out_min_max=(0, 1))

assert rescale(img1).data.flatten().tolist() == [0, 1]
assert rescale(img2).data.flatten().tolist() == [0, 1]

rescale = tio.RescaleIntensity(out_min_max=(0, 1))

assert rescale(img2).data.flatten().tolist() == [0, 1]
assert rescale(img1).data.flatten().tolist() == [0, 1]

0 comments on commit 7a1f109

Please sign in to comment.