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

Method test_correct_results

tests/transforms/test_rand_zoom.py:37–68  ·  view source on GitHub ↗
(self, min_zoom, max_zoom, mode, keep_size, align_corners=None)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

RandZoomClass · 0.90
test_resampler_lazyFunction · 0.90
test_local_inversionFunction · 0.90
assert_allcloseFunction · 0.90
astypeMethod · 0.80
set_random_stateMethod · 0.45

Tested by

no test coverage detected