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

Method test_transpose

tests/transforms/test_transposed.py:34–48  ·  view source on GitHub ↗
(self, im, indices)

Source from the content-addressed store, hash-verified

32class TestTranspose(unittest.TestCase):
33 @parameterized.expand(TESTS)
34 def test_transpose(self, im, indices):
35 data = {"i": deepcopy(im), "j": deepcopy(im)}
36 tr = Transposed(["i", "j"], indices)
37 out_data = tr(data)
38 out_im1, out_im2 = out_data["i"], out_data["j"]
39 if isinstance(im, torch.Tensor):
40 im = im.cpu().numpy()
41 out_gt = np.transpose(im, indices)
42 assert_allclose(out_im1, out_gt, type_test=False)
43 assert_allclose(out_im2, out_gt, type_test=False)
44
45 # test inverse
46 fwd_inv_data = tr.inverse(out_data)
47 for i, j in zip(data.values(), fwd_inv_data.values()):
48 assert_allclose(i, j, type_test=False)
49
50
51if __name__ == "__main__":

Callers

nothing calls this directly

Calls 3

inverseMethod · 0.95
TransposedClass · 0.90
assert_allcloseFunction · 0.90

Tested by

no test coverage detected