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

Method test_torch

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

Source from the content-addressed store, hash-verified

63
64 @parameterized.expand(TORCH_CASES)
65 def test_torch(self, spatial_axis, img: torch.Tensor, track_meta: bool, device):
66 set_track_meta(track_meta)
67 img = img.to(device)
68 init_param = {"keys": "image", "spatial_axis": spatial_axis}
69 xform = Flipd(**init_param)
70 call_param = {"data": {"image": img}}
71 res = xform(**call_param) # type: ignore
72 self.assertEqual(img.shape, res["image"].shape)
73 if track_meta:
74 test_resampler_lazy(xform, res, init_param, call_param, output_key="image")
75 self.assertIsInstance(res["image"], MetaTensor)
76 else:
77 self.assertNotIsInstance(res["image"], MetaTensor)
78 self.assertIsInstance(res["image"], torch.Tensor)
79 with self.assertRaisesRegex(ValueError, "MetaTensor"):
80 xform.inverse(res)
81
82 @unittest.skipIf(not config.USE_META_DICT, "not using meta dict")
83 def test_meta_dict(self):

Callers

nothing calls this directly

Calls 4

inverseMethod · 0.95
set_track_metaFunction · 0.90
FlipdClass · 0.90
test_resampler_lazyFunction · 0.90

Tested by

no test coverage detected