Skip to content

Commit

Permalink
fix compressors
Browse files Browse the repository at this point in the history
Co-authored-by: Matthew Iannucci <mpiannucci@users.noreply.github.com>
  • Loading branch information
dcherian and mpiannucci committed Jan 6, 2025
1 parent ffeb009 commit 4a85fcd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions xarray/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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})

Expand Down

0 comments on commit 4a85fcd

Please sign in to comment.