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

Method test_pending_ops

tests/transforms/test_zoom.py:47–65  ·  view source on GitHub ↗
(self, zoom, mode, align_corners=False, keep_size=False)

Source from the content-addressed store, hash-verified

45class TestZoom(NumpyImageTestCase2D):
46 @parameterized.expand(VALID_CASES)
47 def test_pending_ops(self, zoom, mode, align_corners=False, keep_size=False):
48 im = MetaTensor(self.imt[0], meta={"a": "b", "affine": DEFAULT_TEST_AFFINE})
49 zoom_fn = Zoom(
50 zoom=zoom, mode="bilinear", keep_size=keep_size, dtype=torch.float64, align_corners=align_corners
51 )
52 # non-lazy
53 expected = zoom_fn(im)
54 self.assertIsInstance(expected, MetaTensor)
55 # lazy
56 zoom_fn.lazy = True
57 pending_result = zoom_fn(im)
58 self.assertIsInstance(pending_result, MetaTensor)
59 assert_allclose(pending_result.peek_pending_affine(), expected.affine)
60 assert_allclose(pending_result.peek_pending_shape(), expected.shape[1:])
61 overrides = {"mode": "bilinear", "dtype": np.float64, "align_corners": align_corners}
62 result = apply_pending(pending_result, overrides=overrides)[0]
63 # compare
64 match_ratio = np.sum(np.isclose(result, expected)) / np.prod(result.shape)
65 self.assertGreater(match_ratio, 0.95)
66
67 @parameterized.expand(VALID_CASES)
68 def test_correct_results(self, zoom, mode, *_):

Callers

nothing calls this directly

Calls 6

MetaTensorClass · 0.90
ZoomClass · 0.90
assert_allcloseFunction · 0.90
apply_pendingFunction · 0.90
peek_pending_affineMethod · 0.80
peek_pending_shapeMethod · 0.80

Tested by

no test coverage detected