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

Method test_different_transforms

tests/data/test_gdsdataset.py:208–219  ·  view source on GitHub ↗

Different instances of `GDSDataset` with the same cache_dir, same input data, but different transforms should give different results.

(self)

Source from the content-addressed store, hash-verified

206 self.assertEqual(dataset_postcached[1]["extra"], os.path.join(tempdir, "test_extra2_new.nii.gz"))
207
208 def test_different_transforms(self):
209 """
210 Different instances of `GDSDataset` with the same cache_dir,
211 same input data, but different transforms should give different results.
212 """
213 shape = (1, 10, 9, 8)
214 im = np.arange(0, np.prod(shape)).reshape(shape)
215 with tempfile.TemporaryDirectory() as path:
216 im1 = GDSDataset([im], Identity(), cache_dir=path, hash_transform=json_hashing, device=0)[0]
217 im2 = GDSDataset([im], Flip(1), cache_dir=path, hash_transform=json_hashing, device=0)[0]
218 l2 = ((im1 - im2) ** 2).sum() ** 0.5
219 self.assertTrue(l2 > 1)
220
221
222if __name__ == "__main__":

Callers

nothing calls this directly

Calls 3

GDSDatasetClass · 0.90
IdentityClass · 0.90
FlipClass · 0.90

Tested by

no test coverage detected