edges_io.h5.HDF5Object#

class edges_io.h5.HDF5Object(*args, **kwargs)[source]#

An object that provides a transparent wrapper of a HDF5 file.

Creation of this object can be done in two ways: either by passing a filename to wrap, or by using .from_data, in which case you must pass all the data to it, which it can write in the correct format.

This class exists to be subclassed. Subclasses should define the attribute _structure, which defines the layout of the underlying file. The attribute _require_all sets whether checks on the file will fail if not all keys in the structure are present in the file. Conversely _require_no_extra sets whether it will fail if extra keys are present.

Parameters:
  • filename (str or Path) – The filename of the HDF5 file to wrap.

  • require_all (bool, optional) – Over-ride the class attribute requiring all the structure to exist in file.

  • require_no_extra (bool, optional) – Over-ride the class attribute requiring no extra data to exist in file.

Notes

Accessing data is very similar to just using the h5py.File, except that the object is able to check the structure of the file, and is slightly more convenient.

Note that an .open method exists which returns an open h5py.File object. This is a context manager so you can do things like:

with obj.open() as fl:
    val = fl.attrs['key']

Methods

__init__([filename, group_path, ...])

Method generated by attrs for class HDF5Object.

cached_keys()

All of the keys that have already been read into cache.

check(filename[, false_if_extra])

clear([keys])

Clear all items from memory loaded from file.

from_data(data[, validate])

items()

keys()

open([mode])

Context manager for opening up the file.

write([filename, clobber])

Attributes

default_root

meta

Metadata of the object.

filename

validate