Skip to content

fix: handle H5Dataset missing fillvalue attribute with dtype-based fallback#993

Merged
maxrjones merged 3 commits into
fix/problem_fillvaluesfrom
fix/no-fillvalue-attribute
May 18, 2026
Merged

fix: handle H5Dataset missing fillvalue attribute with dtype-based fallback#993
maxrjones merged 3 commits into
fix/problem_fillvaluesfrom
fix/no-fillvalue-attribute

Conversation

@abarciauskas-bgse

@abarciauskas-bgse abarciauskas-bgse commented May 14, 2026

Copy link
Copy Markdown
Collaborator

This PR handles H5Dataset missing fillvalue attribute with dtype-based fallback

Some h5py.Dataset objects do not expose a fillvalue attribute. This PR guards against AttributeError in _get_fill_value and fall back to np.ma.default_fill_value for the dataset's dtype. Adds a unit test covering this path.

What I did

I discovered this issue when trying to use HDFParser with a GPM IMERG HH HDF5 file

##Acceptance criteria:

  • Closes #xxx -- There are at least 24 open issues related to fill value and I don't know if this applies to any of them
  • Tests added
  • Tests passing
  • No test coverage regression
  • Full type hint coverage
  • Changes are documented in docs/releases.md
  • New functions/methods are listed in an appropriate *.md file under docs/api n/a
  • New functionality has documentation n/a

NB: I can open this as a separate PR to main, I just thought it fit in will with the new _get_fill_value created in this PR.

abarciauskas-bgse and others added 2 commits May 14, 2026 16:26
…llback

Some h5py Dataset objects do not expose a fillvalue attribute. Guard against
AttributeError in _get_fill_value and fall back to np.ma.default_fill_value
for the dataset's dtype. Adds a unit test covering this path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@abarciauskas-bgse abarciauskas-bgse marked this pull request as draft May 14, 2026 23:45
h5py.Dataset.fillvalue delegates to the HDF5 C library via Cython and
raises RuntimeError for unsupported dtypes (e.g. variable-length strings,
compound types). AttributeError can never fire on a real h5py.Dataset
since fillvalue is always a defined property.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@abarciauskas-bgse abarciauskas-bgse marked this pull request as ready for review May 14, 2026 23:49
@abarciauskas-bgse abarciauskas-bgse self-assigned this May 14, 2026
@sharkinsspatial

Copy link
Copy Markdown
Collaborator

@abarciauskas-bgse This might be superseded by #988 which I need to update with @maxrjones suggested fixes before finalizing.

@abarciauskas-bgse

Copy link
Copy Markdown
Collaborator Author

@sharkinsspatial Yes, this is a PR into the #988 branch! The issue is that dataset.fillvalue will throw an error if no fillvalue attribute is set at all, which is not handled by #988, as far as I can tell.

@maxrjones maxrjones merged commit ecc6c02 into fix/problem_fillvalues May 18, 2026
2 checks passed
@maxrjones maxrjones deleted the fix/no-fillvalue-attribute branch May 18, 2026 19:40
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.

3 participants