Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/releases.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release notes

## Unreleased

### Bug Fixes

HDFParser now includes a `_get_fill_value` function which wraps `dataset.fillvalue` in a try/except AttributeError.

## v2.6.1 (3rd May 2026)

Adds end-to-end support for inlined chunk references in `ChunkManifest` (read via Kerchunk parsers, write via Kerchunk and Icechunk writers), plus Zarr-Python 3.2.0 compatibility and several bug fixes.
Expand Down
5 changes: 4 additions & 1 deletion virtualizarr/parsers/hdf/hdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ def _get_fill_value(dataset: H5Dataset):
Extract the fill value from an h5py dataset, handling string/bytes dtypes
that don't return numpy scalars from dataset.fillvalue.
"""
raw = dataset.fillvalue
try:
raw = dataset.fillvalue
except RuntimeError:
return np.ma.default_fill_value(dataset.dtype)
if isinstance(raw, bytes):
return raw.decode("utf-8", errors="replace")
elif isinstance(raw, str):
Expand Down
17 changes: 17 additions & 0 deletions virtualizarr/tests/test_parsers/test_hdf/test_hdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,20 @@ def test_netcdf_over_https():
):
np.testing.assert_allclose(ds["z"].min().to_numpy(), -6)
np.testing.assert_allclose(ds["z"].max().to_numpy(), 817)


def test_fillvalue_runtime_error():
from virtualizarr.parsers.hdf.hdf import _get_fill_value

dtype = np.dtype("float32")

class _RuntimeErrorDataset:
@property
def fillvalue(self):
raise RuntimeError("Unable to get fill value")

dataset = _RuntimeErrorDataset()
dataset.dtype = dtype # type: ignore[attr-defined]

result = _get_fill_value(dataset)
assert result == np.ma.default_fill_value(dtype)