Skip to content

Commit d2a27b6

Browse files
authored
fix: clamp HDF chunk dimensions to >= 1 for zero-length datasets (#977)
Zarr v3 allows `shape=(0,)` but forbids zero-length chunk dimensions, now enforced by zarr-python 3.2.0+. When falling back to `dataset.shape` for chunking, clamp each dim to a minimum of 1 so the HDFParser handles empty HDF5 datasets across all supported zarr versions.
1 parent 8c637b2 commit d2a27b6

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

docs/releases.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
### Bug fixes
1010

11+
- 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.
12+
By [Tom Nicholas](https://github.com/TomNicholas).
13+
1114
### Documentation
1215

1316
### Internal changes

virtualizarr/parsers/hdf/hdf.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ def _construct_manifest_array(
5656
-------
5757
ManifestArray
5858
"""
59-
chunks = dataset.chunks or dataset.shape
59+
# Clamp each dim to >= 1: zarr v3 allows shape=(0,) but forbids zero-length
60+
# chunk dimensions (enforced by zarr-python >= 3.2.0). See
61+
# https://github.com/zarr-developers/zarr-python/issues/3711.
62+
chunks = dataset.chunks or tuple(max(s, 1) for s in dataset.shape)
6063
codecs = codecs_from_dataset(dataset)
6164
attrs = _extract_attrs(dataset)
6265
dtype = dataset.dtype

0 commit comments

Comments
 (0)