|
19 | 19 | from torch.nn.functional import pad
|
20 | 20 |
|
21 | 21 | from monai.inferers import ZarrAvgMerger
|
22 |
| -from monai.utils import optional_import |
| 22 | +from monai.utils import get_package_version, optional_import, version_geq |
23 | 23 | from tests.utils import assert_allclose
|
24 | 24 |
|
25 | 25 | np.seterr(divide="ignore", invalid="ignore")
|
26 | 26 | zarr, has_zarr = optional_import("zarr")
|
| 27 | +if has_zarr: |
| 28 | + if version_geq(get_package_version("zarr"), "3.0.0"): |
| 29 | + directory_store = zarr.storage.LocalStore("test.zarr") |
| 30 | + else: |
| 31 | + directory_store = zarr.storage.DirectoryStore("test.zarr") |
| 32 | +else: |
| 33 | + directory_store = None |
27 | 34 | numcodecs, has_numcodecs = optional_import("numcodecs")
|
28 | 35 |
|
29 | 36 | TENSOR_4x4 = torch.randint(low=0, high=255, size=(2, 3, 4, 4), dtype=torch.float32)
|
|
154 | 161 |
|
155 | 162 | # explicit directory store
|
156 | 163 | TEST_CASE_10_DIRECTORY_STORE = [
|
157 |
| - dict(merged_shape=TENSOR_4x4.shape, store=zarr.storage.DirectoryStore("test.zarr")), |
| 164 | + dict(merged_shape=TENSOR_4x4.shape, store=directory_store), |
158 | 165 | [
|
159 | 166 | (TENSOR_4x4[..., :2, :2], (0, 0)),
|
160 | 167 | (TENSOR_4x4[..., :2, 2:], (0, 2)),
|
|
0 commit comments