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

Function test_local_inversion

tests/test_utils.py:858–870  ·  view source on GitHub ↗

test that invertible_xform can bring to_invert back to im

(invertible_xform, to_invert, im, dict_key=None)

Source from the content-addressed store, hash-verified

856
857
858def test_local_inversion(invertible_xform, to_invert, im, dict_key=None):
859 """test that invertible_xform can bring to_invert back to im"""
860 im_item = im if dict_key is None else im[dict_key]
861 if not isinstance(im_item, MetaTensor):
862 return
863 im_ref = copy.deepcopy(im)
864 im_inv = invertible_xform.inverse(to_invert)
865 if dict_key:
866 im_inv = im_inv[dict_key]
867 im_ref = im_ref[dict_key]
868 np.testing.assert_array_equal(im_inv.applied_operations, [])
869 assert_allclose(im_inv.shape, im_ref.shape)
870 assert_allclose(im_inv.affine, im_ref.affine, atol=1e-3, rtol=1e-3)
871
872
873def command_line_tests(cmd, copy_env=True):

Callers 15

test_correct_resultsMethod · 0.90
test_defaultMethod · 0.90
test_kMethod · 0.90
test_spatial_axesMethod · 0.90
test_correct_resultsMethod · 0.90
test_correct_resultsMethod · 0.90
test_correct_resultsMethod · 0.90
test_correct_resultsMethod · 0.90
test_defaultMethod · 0.90
test_kMethod · 0.90
test_spatial_axesMethod · 0.90

Calls 2

assert_allcloseFunction · 0.85
inverseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…