Different instances of `GDSDataset` with the same cache_dir, same input data, but different transforms should give different results.
(self)
| 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 | |
| 222 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected