|
23 | 23 | from monai.data import GDSDataset, json_hashing |
24 | 24 | from monai.transforms import Compose, Flip, Identity, LoadImaged, SimulateDelayd, Transform |
25 | 25 | from monai.utils import optional_import |
26 | | -from tests.utils import TEST_NDARRAYS, assert_allclose |
| 26 | +from tests.utils import TEST_NDARRAYS, assert_allclose, skip_if_no_cuda |
27 | 27 |
|
28 | 28 | _, has_cp = optional_import("cupy") |
29 | 29 | nib, has_nib = optional_import("nibabel") |
@@ -70,9 +70,9 @@ def __call__(self, data): |
70 | 70 | return data |
71 | 71 |
|
72 | 72 |
|
| 73 | +@skip_if_no_cuda |
73 | 74 | @unittest.skipUnless(has_cp, "Requires CuPy library.") |
74 | | -@unittest.skipUnless(has_nib, "Requires nibabel package.") |
75 | | -@unittest.skipUnless(has_kvikio_numpy, "Requires scikit-image library.") |
| 75 | +@unittest.skipUnless(has_cp and has_kvikio_numpy, "Requires CuPy and kvikio library.") |
76 | 76 | class TestDataset(unittest.TestCase): |
77 | 77 |
|
78 | 78 | def test_cache(self): |
@@ -131,6 +131,7 @@ def test_dtype(self): |
131 | 131 | self.assertEqual(ds[0].dtype, DTYPES[_dtype]) |
132 | 132 | self.assertEqual(ds1[0].dtype, DTYPES[_dtype]) |
133 | 133 |
|
| 134 | + @unittest.skipUnless(has_nib, "Requires nibabel package.") |
134 | 135 | @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3]) |
135 | 136 | def test_shape(self, transform, expected_shape): |
136 | 137 | test_image = nib.Nifti1Image(np.random.randint(0, 2, size=[128, 128, 128]).astype(float), np.eye(4)) |
|
0 commit comments