diff --git a/docs/releases.md b/docs/releases.md index 9bc4e562..b1c376c2 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -8,6 +8,9 @@ ### Bug fixes +- Fix `HDFParser` failing on HDF5 datasets with a zero-length dimension under `zarr-python >= 3.2.0`, which forbids zero-length chunk dimensions. Chunk dimensions are now clamped to a minimum of 1 when falling back from dataset shape. + By [Tom Nicholas](https://github.com/TomNicholas). + ### Documentation ### Internal changes diff --git a/virtualizarr/parsers/hdf/hdf.py b/virtualizarr/parsers/hdf/hdf.py index a180a502..d9cef4ff 100644 --- a/virtualizarr/parsers/hdf/hdf.py +++ b/virtualizarr/parsers/hdf/hdf.py @@ -56,7 +56,10 @@ def _construct_manifest_array( ------- ManifestArray """ - chunks = dataset.chunks or dataset.shape + # Clamp each dim to >= 1: zarr v3 allows shape=(0,) but forbids zero-length + # chunk dimensions (enforced by zarr-python >= 3.2.0). See + # https://github.com/zarr-developers/zarr-python/issues/3711. + chunks = dataset.chunks or tuple(max(s, 1) for s in dataset.shape) codecs = codecs_from_dataset(dataset) attrs = _extract_attrs(dataset) dtype = dataset.dtype