From 4a85fcdb0962d575a5686bea6695cd8a709e42d7 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Mon, 6 Jan 2025 16:06:06 -0700 Subject: [PATCH] fix compressors Co-authored-by: Matthew Iannucci --- xarray/tests/test_backends.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/xarray/tests/test_backends.py b/xarray/tests/test_backends.py index c5e308215b5..9a2c2bd3137 100644 --- a/xarray/tests/test_backends.py +++ b/xarray/tests/test_backends.py @@ -2675,18 +2675,15 @@ def test_write_persistence_modes(self, group) -> None: assert_identical(original, actual) def test_compressor_encoding(self) -> None: - from numcodecs.blosc import Blosc - - original = create_test_data() # specify a custom compressor - + original = create_test_data() if has_zarr_v3 and zarr.config.config["default_zarr_format"] == 3: encoding_key = "compressors" # all parameters need to be explicitly specified in order for the comparison to pass below encoding = { "serializer": zarr.codecs.BytesCodec(endian="little"), encoding_key: ( - Blosc( + zarr.codecs.BloscCodec( cname="zstd", clevel=3, shuffle="shuffle", @@ -2696,8 +2693,11 @@ def test_compressor_encoding(self) -> None: ), } else: + from numcodecs.blosc import Blosc + encoding_key = "compressors" if has_zarr_v3 else "compressor" - encoding = {encoding_key: (Blosc(cname="zstd", clevel=3, shuffle=2),)} + comp = Blosc(cname="zstd", clevel=3, shuffle=2) + encoding = {encoding_key: (comp,) if has_zarr_v3 else comp} save_kwargs = dict(encoding={"var1": encoding})