Make HGroup more robust to changes in h5py.Group#5284
Open
GarethCabournDavies wants to merge 7 commits intogwastro:masterfrom
Open
Make HGroup more robust to changes in h5py.Group#5284GarethCabournDavies wants to merge 7 commits intogwastro:masterfrom
GarethCabournDavies wants to merge 7 commits intogwastro:masterfrom
Conversation
ahnitz
reviewed
Feb 12, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates pycbc.io.hdf.HGroup/HFile wrappers to be more resilient to upstream h5py.Group behavior changes, particularly around create_dataset and enforcing fletcher32 checksums, and adds new unit tests covering dataset creation parity, HGroup wrapping, and several pycbc.io.hdf utilities.
Changes:
- Refactor
HGroup.create_groupto delegate toh5pyand always return anHGroup. - Rework
HGroup.create_datasetto auto-enable fletcher32 for numeric, non-scalar datasets and add wrapping behavior for__getitem__andparent. - Add new test modules for checksum behavior, HGroup wrapping,
HFile.select,FileData,DictArray, andDataFromFiles.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
pycbc/io/hdf.py |
Refactors HGroup wrappers for group/dataset creation and subgroup access, and adds parent wrapping. |
test/test_io_hgroup.py |
Adds tests for fletcher32 enablement rules and HGroup wrapping semantics. |
test/test_io_hdf.py |
Adds tests for HFile.select, FileData, DictArray.save, and DataFromFiles. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ahnitz
reviewed
Feb 13, 2026
ahnitz
approved these changes
Feb 18, 2026
Member
ahnitz
left a comment
There was a problem hiding this comment.
You've addressed my primary concern. Also, thank you for the unittest (even if they may be AI assisted). They look reasonable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There were some changes to h5py's create_dataset which I didn't see for a while. This change will make HGroup more robust to changes in h5py.Group as a result
Ive extended the checking for which situations need flecther32 checksums enabled, I dont think this is necessary for the situations we have now, but it is for safety in the future.
I've also added a couple of unit testing modules (largely written by copilot to be fair) which tests many different methods of creation, whether the datasets are the same after being loaded etc., and whether fletcher32 is enabled or not. The wider hdf.py checks are for things like the bool and indexing selections.
Standard information about the request
This change touches all areas which use h5py for saving files (which is everywhere), but actually affects nothing
This change: has appropriate unit tests, follows style guidelines (See e.g. PEP8), has been proposed using the contribution guidelines
Motivation
I didn't want to rely on me getting automated emails of whether a file has changed any more (by the evidence already, this doesn't work)
Links to any issues or associated PRs
extends #4831
Testing performed
unit tests added so that the testing is done automatically