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

Method get_im

tests/data/meta_tensor/test_meta_tensor.py:52–63  ·  view source on GitHub ↗
(shape=None, dtype=None, device=None)

Source from the content-addressed store, hash-verified

50class TestMetaTensor(unittest.TestCase):
51 @staticmethod
52 def get_im(shape=None, dtype=None, device=None):
53 if shape is None:
54 shape = (1, 10, 8)
55 affine = torch.randint(0, 10, (4, 4))
56 meta = {"fname": rand_string()}
57 t = torch.rand(shape)
58 if dtype is not None:
59 t = t.to(dtype)
60 if device is not None:
61 t = t.to(device)
62 m = MetaTensor(t.clone(), affine, meta)
63 return m, t
64
65 def check_ids(self, a, b, should_match):
66 comp = self.assertEqual if should_match else self.assertNotEqual

Callers 15

test_as_tensorMethod · 0.95
test_as_dictMethod · 0.95
test_constructorMethod · 0.95
test_to_cudaMethod · 0.95
test_affine_deviceMethod · 0.95
test_copyMethod · 0.95
test_addMethod · 0.95
test_convMethod · 0.95
test_stackMethod · 0.95
test_torchscriptMethod · 0.95
test_picklingMethod · 0.95
test_ampMethod · 0.95

Calls 3

MetaTensorClass · 0.90
cloneMethod · 0.80
rand_stringFunction · 0.70

Tested by

no test coverage detected