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

Method check

tests/transforms/utility/test_rand_lambda.py:40–59  ·  view source on GitHub ↗
(self, tr: RandLambda, img, img_orig_type, out, expected=None)

Source from the content-addressed store, hash-verified

38
39class TestRandLambda(unittest.TestCase):
40 def check(self, tr: RandLambda, img, img_orig_type, out, expected=None):
41 # input shouldn't change
42 self.assertIsInstance(img, img_orig_type)
43 if isinstance(img, MetaTensor):
44 self.assertEqual(len(img.applied_operations), 0)
45 # output data matches expected
46 assert_allclose(expected, out, type_test=False)
47 # output type is MetaTensor with 1 appended operation
48 self.assertIsInstance(out, MetaTensor)
49 self.assertEqual(len(out.applied_operations), 1)
50
51 # inverse
52 inv = tr.inverse(out)
53 # after inverse, input image remains unchanged
54 self.assertIsInstance(img, img_orig_type)
55 if isinstance(img, MetaTensor):
56 self.assertEqual(len(img.applied_operations), 0)
57 # after inverse, output is MetaTensor with 0 applied operations
58 self.assertIsInstance(inv, MetaTensor)
59 self.assertEqual(len(inv.applied_operations), 0)
60
61 @parameterized.expand([[p] for p in TEST_NDARRAYS])
62 def test_rand_lambdad_identity(self, t):

Callers 1

Calls 2

assert_allcloseFunction · 0.90
inverseMethod · 0.45

Tested by

no test coverage detected