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

Method test_correct_results

tests/transforms/test_zoomd.py:38–71  ·  view source on GitHub ↗
(self, zoom, mode, keep_size, align_corners=None)

Source from the content-addressed store, hash-verified

36class TestZoomd(NumpyImageTestCase2D):
37 @parameterized.expand(VALID_CASES)
38 def test_correct_results(self, zoom, mode, keep_size, align_corners=None):
39 key = "img"
40 init_param = {
41 "keys": key,
42 "zoom": zoom,
43 "mode": mode,
44 "keep_size": keep_size,
45 "dtype": torch.float64,
46 "align_corners": align_corners,
47 }
48 zoom_fn = Zoomd(**init_param)
49 for p in TEST_NDARRAYS_ALL:
50 im = p(self.imt[0])
51 call_param = {"data": {key: im}}
52 zoomed = zoom_fn(**call_param)
53
54 # test lazy
55 # TODO: temporarily skip "nearest" test
56 if mode == "bilinear":
57 test_resampler_lazy(
58 zoom_fn, zoomed, init_param, call_param, output_key=key, atol=1e-4 if USE_COMPILED else 1e-6
59 )
60 zoom_fn.lazy = False
61
62 test_local_inversion(zoom_fn, zoomed, {key: im}, key)
63 _order = 0
64 if mode.endswith("linear"):
65 _order = 1
66 expected = [
67 zoom_scipy(channel, zoom=zoom, mode="nearest", order=_order, prefilter=False) for channel in self.imt[0]
68 ]
69
70 expected = np.stack(expected).astype(np.float32)
71 assert_allclose(zoomed[key], p(expected), atol=1.0, type_test=False)
72
73 def test_keep_size(self):
74 key = "img"

Callers

nothing calls this directly

Calls 5

ZoomdClass · 0.90
test_resampler_lazyFunction · 0.90
test_local_inversionFunction · 0.90
assert_allcloseFunction · 0.90
astypeMethod · 0.80

Tested by

no test coverage detected