From 53c7e68212fa127adecd3268ba87af7731a1bfe2 Mon Sep 17 00:00:00 2001 From: Ian Hunt-Isaak Date: Tue, 16 Sep 2025 14:52:11 -0400 Subject: [PATCH 1/2] Fix Blosc import in test for zarr 3.1.13 --- xarray/tests/test_backends_datatree.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xarray/tests/test_backends_datatree.py b/xarray/tests/test_backends_datatree.py index 8d03781592d..183530cd434 100644 --- a/xarray/tests/test_backends_datatree.py +++ b/xarray/tests/test_backends_datatree.py @@ -678,9 +678,10 @@ def test_zarr_encoding(self, tmpdir, simple_datatree, zarr_format) -> None: comp = {"compressors": (codec,)} if has_zarr_v3 else {"compressor": codec} elif zarr_format == 3: # specifying codecs in zarr_format=3 requires importing from zarr 3 namespace - import numcodecs.zarr3 + from zarr.registry import get_codec_class - comp = {"compressors": (numcodecs.zarr3.Blosc(cname="zstd", clevel=3),)} + Blosc = get_codec_class("numcodecs.blosc") + comp = {"compressors": (Blosc(cname="zstd", clevel=3),)} enc = {"/set2": dict.fromkeys(original_dt["/set2"].dataset.data_vars, comp)} original_dt.to_zarr(filepath, encoding=enc, zarr_format=zarr_format) From 5c5b2a4bbe661324b02718e74e767309b12173ac Mon Sep 17 00:00:00 2001 From: Ian Hunt-Isaak Date: Tue, 16 Sep 2025 15:01:34 -0400 Subject: [PATCH 2/2] mypy --- xarray/tests/test_backends_datatree.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xarray/tests/test_backends_datatree.py b/xarray/tests/test_backends_datatree.py index 183530cd434..b2237044cff 100644 --- a/xarray/tests/test_backends_datatree.py +++ b/xarray/tests/test_backends_datatree.py @@ -681,7 +681,7 @@ def test_zarr_encoding(self, tmpdir, simple_datatree, zarr_format) -> None: from zarr.registry import get_codec_class Blosc = get_codec_class("numcodecs.blosc") - comp = {"compressors": (Blosc(cname="zstd", clevel=3),)} + comp = {"compressors": (Blosc(cname="zstd", clevel=3),)} # type: ignore[call-arg] enc = {"/set2": dict.fromkeys(original_dt["/set2"].dataset.data_vars, comp)} original_dt.to_zarr(filepath, encoding=enc, zarr_format=zarr_format)