Skip to content

fix: handle zero-length dimensions in HDFParser for zarr-python 3.2.0#977

Merged
TomNicholas merged 1 commit intozarr-developers:mainfrom
TomNicholas:fix-hdf-zero-length-chunks
Apr 22, 2026
Merged

fix: handle zero-length dimensions in HDFParser for zarr-python 3.2.0#977
TomNicholas merged 1 commit intozarr-developers:mainfrom
TomNicholas:fix-hdf-zero-length-chunks

Conversation

@TomNicholas
Copy link
Copy Markdown
Member

Summary

  • Zarr v3 allows shape=(0,) but forbids zero-length chunk dimensions, now enforced by zarr-python 3.2.0+ (see zarr-developers/zarr-python#3711).
  • HDFParser previously fell back to dataset.shape for the chunk shape when dataset.chunks was None, producing an invalid chunk_shape=(0,) for empty HDF5 datasets.
  • Fix clamps each chunk dim to >= 1, so empty HDF5 datasets round-trip cleanly on both zarr 3.1.x and 3.2.0+.

Unblocks the test_empty_dataset failure noted in #957.

Test plan

  • test_empty_dataset passes on zarr 3.1.6
  • test_empty_dataset passes on zarr >=3.2.0 (verified that zarr accepts shape=(0,), chunks=(1,) on both dev and released builds; full upstream-zarr test run blocked until Add compatibility with Zarr-Python 3.2.0 #957 lands and provides the RegularChunkGridMetadata import shim)
  • No regressions in virtualizarr/tests/test_parsers/test_hdf/

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.
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.31%. Comparing base (b3899e1) to head (88c3d8c).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #977   +/-   ##
=======================================
  Coverage   89.31%   89.31%           
=======================================
  Files          33       33           
  Lines        2031     2031           
=======================================
  Hits         1814     1814           
  Misses        217      217           
Files with missing lines Coverage Δ
virtualizarr/parsers/hdf/hdf.py 95.58% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TomNicholas TomNicholas merged commit d2a27b6 into zarr-developers:main Apr 22, 2026
17 checks passed
@TomNicholas TomNicholas deleted the fix-hdf-zero-length-chunks branch April 22, 2026 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant