Skip to content

Commit d14b6bf

Browse files
KumoLiuericspod
authored andcommitted
Using LocalStore in Zarr v3 (Project-MONAI#8299)
Fixes Project-MONAI#8298 ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Signed-off-by: Can-Zhao <volcanofly@gmail.com>
1 parent 5da95c8 commit d14b6bf

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/test_zarr_avg_merger.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,18 @@
1919
from torch.nn.functional import pad
2020

2121
from monai.inferers import ZarrAvgMerger
22-
from monai.utils import optional_import
22+
from monai.utils import get_package_version, optional_import, version_geq
2323
from tests.utils import assert_allclose
2424

2525
np.seterr(divide="ignore", invalid="ignore")
2626
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
2734
numcodecs, has_numcodecs = optional_import("numcodecs")
2835

2936
TENSOR_4x4 = torch.randint(low=0, high=255, size=(2, 3, 4, 4), dtype=torch.float32)
@@ -154,7 +161,7 @@
154161

155162
# explicit directory store
156163
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),
158165
[
159166
(TENSOR_4x4[..., :2, :2], (0, 0)),
160167
(TENSOR_4x4[..., :2, 2:], (0, 2)),

0 commit comments

Comments
 (0)