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

Method test_collate

tests/data/meta_tensor/test_meta_tensor.py:275–290  ·  view source on GitHub ↗
(self, device, dtype)

Source from the content-addressed store, hash-verified

273
274 @parameterized.expand(TESTS)
275 def test_collate(self, device, dtype):
276 numel = 3
277 ims = [self.get_im(device=device, dtype=dtype)[0] for _ in range(numel)]
278 ims = [MetaTensor(im, applied_operations=[f"t{i}"]) for i, im in enumerate(ims)]
279 collated = list_data_collate(ims)
280 # tensor
281 self.assertIsInstance(collated, MetaTensor)
282 expected_shape = (numel,) + tuple(ims[0].shape)
283 self.assertTupleEqual(tuple(collated.shape), expected_shape)
284 for i, im in enumerate(ims):
285 self.check(im, ims[i], ids=True)
286 # affine
287 self.assertIsInstance(collated.affine, torch.Tensor)
288 expected_shape = (numel,) + tuple(ims[0].affine.shape)
289 self.assertTupleEqual(tuple(collated.affine.shape), expected_shape)
290 self.assertEqual(len(collated.applied_operations), numel)
291
292 @parameterized.expand(TESTS)
293 def test_dataset(self, device, dtype):

Callers

nothing calls this directly

Calls 4

get_imMethod · 0.95
checkMethod · 0.95
MetaTensorClass · 0.90
list_data_collateFunction · 0.90

Tested by

no test coverage detected