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

Method check

tests/data/meta_tensor/test_meta_tensor.py:80–110  ·  view source on GitHub ↗
(
        self,
        out: torch.Tensor,
        orig: torch.Tensor,
        *,
        shape: bool = True,
        vals: bool = True,
        ids: bool = True,
        device: str | torch.device | None = None,
        meta: bool = True,
        check_ids: bool = True,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

78 self.assertEqual(meta_a, meta_b)
79
80 def check(
81 self,
82 out: torch.Tensor,
83 orig: torch.Tensor,
84 *,
85 shape: bool = True,
86 vals: bool = True,
87 ids: bool = True,
88 device: str | torch.device | None = None,
89 meta: bool = True,
90 check_ids: bool = True,
91 **kwargs,
92 ):
93 if device is None:
94 device = orig.device
95
96 # check the image
97 self.assertIsInstance(out, type(orig))
98 if shape:
99 assert_allclose(torch.as_tensor(out.shape), torch.as_tensor(orig.shape))
100 if vals:
101 assert_allclose(out, orig, **kwargs)
102 if check_ids:
103 self.check_ids(out, orig, ids)
104 self.assertTrue(str(device) in str(out.device))
105
106 # check meta and affine are equal and affine is on correct device
107 if isinstance(orig, MetaTensor) and isinstance(out, MetaTensor) and meta:
108 self.check_meta(orig, out)
109 if check_ids:
110 self.check_ids(out.meta, orig.meta, ids)
111
112 @parameterized.expand(TESTS)
113 def test_as_tensor(self, device, dtype):

Callers 14

test_as_tensorMethod · 0.95
test_as_dictMethod · 0.95
test_constructorMethod · 0.95
test_to_cudaMethod · 0.95
test_copyMethod · 0.95
test_addMethod · 0.95
test_convMethod · 0.95
test_torchscriptMethod · 0.95
test_picklingMethod · 0.95
test_ampMethod · 0.95
test_collateMethod · 0.95
test_datasetMethod · 0.95

Calls 4

check_idsMethod · 0.95
check_metaMethod · 0.95
assert_allcloseFunction · 0.90
as_tensorMethod · 0.80

Tested by

no test coverage detected