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

Method test_correct_results

tests/transforms/test_rand_zoomd.py:35–70  ·  view source on GitHub ↗
(self, min_zoom, max_zoom, mode, align_corners, keep_size)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

set_random_stateMethod · 0.95
RandZoomdClass · 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