|
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(f"{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") |
27 | 32 | numcodecs, has_numcodecs = optional_import("numcodecs") |
28 | 33 |
|
29 | 34 | TENSOR_4x4 = torch.randint(low=0, high=255, size=(2, 3, 4, 4), dtype=torch.float32) |
|
154 | 159 |
|
155 | 160 | # explicit directory store |
156 | 161 | TEST_CASE_10_DIRECTORY_STORE = [ |
157 | | - dict(merged_shape=TENSOR_4x4.shape, store=zarr.storage.DirectoryStore("test.zarr")), |
| 162 | + dict(merged_shape=TENSOR_4x4.shape, store=directory_store), |
158 | 163 | [ |
159 | 164 | (TENSOR_4x4[..., :2, :2], (0, 0)), |
160 | 165 | (TENSOR_4x4[..., :2, 2:], (0, 2)), |
|
0 commit comments