MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / test_int

Method test_int

tests/transforms/test_scale_intensity.py:50–60  ·  view source on GitHub ↗

integers should be handled by converting them to floats first.

(self)

Source from the content-addressed store, hash-verified

48 assert_allclose(result, expected, type_test="tensor", rtol=1e-3, atol=1e-3)
49
50 def test_int(self):
51 """integers should be handled by converting them to floats first."""
52 for p in TEST_NDARRAYS:
53 scaler = ScaleIntensity(minv=1.0, maxv=2.0)
54 result = scaler(p(self.imt.astype(int)))
55 _imt = self.imt.astype(int).astype(np.float32)
56 mina = _imt.min()
57 maxa = _imt.max()
58 norm = (_imt - mina) / (maxa - mina)
59 expected = p((norm * (2.0 - 1.0)) + 1.0)
60 assert_allclose(result, expected, type_test="tensor", rtol=1e-7, atol=0)
61
62 def test_channel_wise(self):
63 for p in TEST_NDARRAYS:

Callers

nothing calls this directly

Calls 3

ScaleIntensityClass · 0.90
assert_allcloseFunction · 0.90
astypeMethod · 0.80

Tested by

no test coverage detected