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) -> bool
Arguments:
- key:
str
(self, key) -> None
Deletes 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) -> None
Create 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.Dataset
Arguments:
- name:
str
- shape:
tuple[int, ...]
- dtype
- exact:
bool
=False
- kwargs=
{}
(self, name, vector, attrs=None, dtype=None, *, file_map=True) -> None
Add 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:
str
Name for the dataset
- vector:
ArrayLike
Data to write (max 2d)
- attrs:
typing.Optional[typing.Dict[str, typing.Any]]
=None
Optional. Attributes of dataset.
- dtype:
typing.Optional[str]
=None
Optional. dtype of dataset. If not specified, uses dtype of inpyt array
- file_map:
bool
=True
Optional. If True, the dataset is added to the file map. Default is True.
(self, name, data, attrs=None, dtype=None) -> None
Arguments:
- 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) -> Any
Arguments:
- key:
tuple | slice | int