Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checksums to hdf5 datasets datasets #4831

Merged
Merged
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
35 changes: 34 additions & 1 deletion pycbc/io/hdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,40 @@
logger = logging.getLogger('pycbc.io.hdf')


class HFile(h5py.File):
class HGroup(h5py.Group):
""" Low level extensions to the h5py group object
"""
def create_group(self, name, track_order=None):
"""
Wrapper around h5py's create_group in order to redirect to the
manual HGroup object defined here
"""
if track_order is None:
track_order = h5py.h5.get_config().track_order

with h5py._objects.phil:
name, lcpl = self._e(name, lcpl=True)
gcpl = HGroup._gcpl_crt_order if track_order else None
gid = h5py.h5g.create(self.id, name, lcpl=lcpl, gcpl=gcpl)
return HGroup(gid)

def create_dataset(self, name, shape=None, dtype=None, data=None, **kwds):
"""
Wrapper around h5py's create_dataset so that checksums are used
"""
if hasattr(data, 'dtype') and not data.dtype == object:
kwds['fletcher32'] = True
return h5py.Group.create_dataset(
self,
name,
shape=shape,
dtype=dtype,
data=data,
**kwds
)


class HFile(HGroup, h5py.File):
""" Low level extensions to the capabilities of reading an hdf5 File
"""
def select(self, fcn, *args, chunksize=10**6, derived=None, group='',
Expand Down
Loading