Skip to content

Commit

Permalink
fixup! fixup! zarr-v3: filters / compressors -> codecs
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAugspurger committed Sep 30, 2024
1 parent 25692be commit d11d593
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions xarray/backends/zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
from xarray.core.datatree import DataTree



@functools.lru_cache
def _zarr_v3() -> bool:
try:
Expand Down Expand Up @@ -90,8 +89,10 @@ def __init__(self, zarr_array):
self.shape = self._array.shape

# preserve vlen string object dtype (GH 7328)
if not _zarr_v3() and self._array.filters is not None and any(
[filt.codec_id == "vlen-utf8" for filt in self._array.filters]
if (
not _zarr_v3()
and self._array.filters is not None
and any([filt.codec_id == "vlen-utf8" for filt in self._array.filters])
):
dtype = coding.strings.create_vlen_dtype(str)
else:
Expand Down Expand Up @@ -634,17 +635,23 @@ def open_store_variable(self, name, zarr_array=None):
}

if _zarr_v3() and zarr_array.metadata.zarr_format == 3:
encoding["codec_pipeline"] = [x.to_dict() for x in zarr_array.metadata.codecs]
encoding["codec_pipeline"] = [
x.to_dict() for x in zarr_array.metadata.codecs
]
elif _zarr_v3():
encoding.update({
"compressor": zarr_array.metadata.compressor,
"filters": zarr_array.metadata.filters,
})
encoding.update(
{
"compressor": zarr_array.metadata.compressor,
"filters": zarr_array.metadata.filters,
}
)
else:
encoding.update({
"compressor": zarr_array.compressor,
"filters": zarr_array.filters,
})
encoding.update(
{
"compressor": zarr_array.compressor,
"filters": zarr_array.filters,
}
)

# _FillValue needs to be in attributes, not encoding, so it will get
# picked up by decode_cf
Expand Down

0 comments on commit d11d593

Please sign in to comment.