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

Method test_correct_results

tests/transforms/test_rand_flipd.py:30–51  ·  view source on GitHub ↗
(self, _, spatial_axis)

Source from the content-addressed store, hash-verified

28class TestRandFlipd(NumpyImageTestCase2D):
29 @parameterized.expand(VALID_CASES)
30 def test_correct_results(self, _, spatial_axis):
31 for p in TEST_NDARRAYS_ALL:
32 init_param = {"keys": "img", "prob": 1.0, "spatial_axis": spatial_axis}
33 flip = RandFlipd(**init_param)
34 im = p(self.imt[0])
35 call_param = {"data": {"img": im}}
36 result = flip(**call_param)
37
38 # test lazy
39 test_resampler_lazy(flip, result, init_param, call_param, output_key="img")
40 flip.lazy = False
41
42 expected = [np.flip(channel, spatial_axis) for channel in self.imt[0]]
43 expected = np.stack(expected)
44 assert_allclose(result["img"], p(expected), type_test="tensor")
45 test_local_inversion(flip, {"img": result["img"]}, {"img": im}, "img")
46
47 set_track_meta(False)
48 result = flip({"img": im})["img"]
49 self.assertNotIsInstance(result, MetaTensor)
50 self.assertIsInstance(result, torch.Tensor)
51 set_track_meta(True)
52
53
54if __name__ == "__main__":

Callers

nothing calls this directly

Calls 6

RandFlipdClass · 0.90
test_resampler_lazyFunction · 0.90
assert_allcloseFunction · 0.90
test_local_inversionFunction · 0.90
set_track_metaFunction · 0.90
flipFunction · 0.85

Tested by

no test coverage detected