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

Method test_torch

tests/transforms/test_flip.py:64–79  ·  view source on GitHub ↗
(self, spatial_axis, img: torch.Tensor, track_meta: bool, device)

Source from the content-addressed store, hash-verified

62
63 @parameterized.expand(TORCH_CASES)
64 def test_torch(self, spatial_axis, img: torch.Tensor, track_meta: bool, device):
65 set_track_meta(track_meta)
66 img = img.to(device)
67 init_param = {"spatial_axis": spatial_axis}
68 xform = Flip(**init_param)
69 call_param = {"img": img}
70 res = xform(**call_param) # type: ignore[arg-type]
71 self.assertEqual(img.shape, res.shape)
72 if track_meta:
73 test_resampler_lazy(xform, res, init_param, call_param)
74 self.assertIsInstance(res, MetaTensor)
75 else:
76 self.assertNotIsInstance(res, MetaTensor)
77 self.assertIsInstance(res, torch.Tensor)
78 with self.assertRaisesRegex(ValueError, "MetaTensor"):
79 xform.inverse(res)
80
81
82if __name__ == "__main__":

Callers

nothing calls this directly

Calls 4

inverseMethod · 0.95
set_track_metaFunction · 0.90
FlipClass · 0.90
test_resampler_lazyFunction · 0.90

Tested by

no test coverage detected