bamboost.core.hdf5.ref
This module provides a high-level abstraction for working with HDF5 (h5py) groups and
datasets. It is built on the concept of describing an object in the file with a reference
to it (deterministic reference: a file instance, and a path inside the HDF file).
The reference handles file opening and closing, and provides a simple interface to
data, attributes and subgroups. In essence, this model provides h5py objects like any
other in-memory data structure.
Attributes
- log=
BAMBOOST_LOGGER.getChild('hdf5') - MPI_ACTIVE=
'mpio' in h5py.h5py.registered_drivers() and h5py.h5py.get_config().mpi and bamboost.mpi.MPI_ON - _RT_group=
TypeVar('_RT_group', bound=(Union['Group', 'Dataset'])) - _g=
bamboost.core.hdf5.ref.Group - _d=
bamboost.core.hdf5.ref.Dataset
Classes
RefStatus
Attributes:
- INVALID=
0 - VALID=
1 - NOT_CHECKED=
2
H5Reference
(self, path, file)Arguments:
- path:
str - file:
HDF5File[bamboost._typing._MT]
Attributes:
Bases
(self, value)Arguments:
- value
(self) -> str(cls, path, file, _type=None) -> _RT_group(self)Group
(self, path, file)Arguments:
- path
- file
Attributes:
- _group_map=
FilteredFileMap(file.file_map, path) - _status=
RefStatus(_valid) - _obj:
h5py.h5py.Group
Bases
(self)(self, key) -> boolArguments:
- key:
str
(self, key) -> NoneDeletes an item.
Arguments:
- key
(self, key, newvalue)Used to set an attribute. Will be written as an attribute to the group.
Arguments:
- key
- newvalue
(self)(self)(self)(self, *, filter=None) -> Generator[Tuple[str, Union[Group[_MT], Dataset[_MT]]], None, None]Arguments:
- filter:
typing.Optional[typing.Literal['groups', 'datasets']]=None
(self) -> NoneCreate the group if it doesn't exist yet.
(self, name, *, return_type=None)Create a group if it doesn't exist yet.
Arguments:
- name
- return_type=
None
(self, name, shape, dtype, exact=False, **kwargs) -> h5py.DatasetArguments:
- name:
str - shape:
tuple[int, ...] - dtype
- exact:
bool=False - kwargs=
{}
(self, name, vector, attrs=None, dtype=None, *, file_map=True) -> NoneAdd a dataset to the group. Error is thrown if attempting to overwrite with different shape than before. If same shape, data is overwritten (this is inherited from h5py -> require_dataset)
Arguments:
- name:
strName for the dataset
- vector:
ArrayLikeData to write (max 2d)
- attrs:
typing.Optional[typing.Dict[str, typing.Any]]=NoneOptional. Attributes of dataset.
- dtype:
typing.Optional[str]=NoneOptional. dtype of dataset. If not specified, uses dtype of inpyt array
- file_map:
bool=TrueOptional. If True, the dataset is added to the file map. Default is True.
(self, name, data, attrs=None, dtype=None) -> NoneArguments:
- name:
str - data:
typing.Any - attrs:
typing.Optional[typing.Dict[str, typing.Any]]=None - dtype:
typing.Optional[str]=None
(self)(self)Repr showing the content of the group.
Dataset
Attributes:
- _obj:
h5py.h5py.Dataset - shape:
tuple[int, ...] - dtype
- array:
numpy.numpy.ndarray
Bases
(self, key) -> AnyArguments:
- key:
tuple | slice | int
Bamboost