h5
⚓︎
HDF5 functions, and utils, and generators, OH MY!
Modules:
-
cli–h5.cli
-
core–HDF5 functions, and utils, and generators, OH MY!
-
dev–h5.dev ~ Under construction!
-
legacy–Legacy; to be deprecated
-
testing–
Classes:
-
FileInfo–
Functions:
-
as_h5py_obj–Convert a path or h5py object to an h5py object
-
attrs–Return a generator that yields tuples with: (HDF5-path, HDF5-attr)
-
attrs_dict–Load an HDF5 file from a fspath into a dictionary
-
attrs_gen–Return a generator that yields tuples with: (HDF5-path, HDF5-attr)
-
attrs_gen_from_fspath–Given a fspath to an h5, yield (h5-path, h5py.Dataset) tuples
-
datasets–Return a generator that yields tuples with: (HDF5-path, Dataset)
-
datasets_dict–Load an HDF5 file from a fspath into a dictionary
-
datasets_gen–Return a generator that yields tuples with: (HDF5-path, Dataset)
-
datasets_gen_from_fspath–Given a fspath to an h5, yield (h5-path, h5py.Dataset) tuples
-
datasets_keys_list–Return a list of all keys/paths for an h5py object.
-
fmt_h5_path–Format function for HDF5-path-strings
-
groups–Return a generator that yields tuples with: (HDF5-path, h5py.Group)
-
groups_gen–Return a generator that yields tuples with: (HDF5-path, h5py.Group)
-
groups_gen_from_fspath–Given a fspath to an h5, yield (h5-path, h5py.Dataset) tuples
-
h5_attrs_dict–Alias for h5.attrs_dict
-
h5_attrs_gen–Alias for h5.datasets_gen
-
h5_attrs_gen_from_fspath–Given a fspath to an h5, yield (h5-path, h5py.Dataset) tuples
-
h5_datasets_dict–Alias for h5.datasets_dict
-
h5_datasets_gen–Alias for h5.datasets_gen
-
h5_datasets_gen_from_fspath–Given a fspath to an h5, yield (h5-path, h5py.Dataset) tuples
-
h5py_obj_attrs_gen–Recursive h5py.AttributeManager generator.
-
h5py_obj_dataset_gen–Recursive h5 dataset generator.
-
h5py_obj_gen–Recursive h5 dataset/group generator.
-
h5py_obj_groups_gen–Recursive h5 groups generator.
-
h5py_obj_keys_gen–Recursive h5 dataset generator.
-
is_dataset–h5py.Dataset type guard
-
is_file–h5py.File type guard
-
is_group–h5py.Group type guard
-
is_h5py_dataset–h5py.Dataset type guard
-
is_h5py_file–h5py.File type guard
-
is_h5py_group–h5py.Group type guard
-
is_hdf5–Check if a file is an HDF5 file
-
keys_list–Return a list of all keys/paths for an h5py object.
Attributes:
-
H5pyCompression(TypeAlias) –h5py mode strings (taken from h5py docstrings)):
H5pyCompression
module-attribute
⚓︎
h5py mode strings (taken from h5py docstrings)):
r Readonly, file must exist (default)
r+ Read/write, file must exist
w Create file, truncate if exists
w- or x Create file, fail if exists
a Read/write if exists, create otherwise
FileInfo
dataclass
⚓︎
FileInfo(
groups: dict[str, GroupInfo],
attrs: dict[str, Any],
datasets: dict[str, DatasetInfo],
fspath: str,
fssize: int,
key: str,
h5type: Literal["file"],
)
Bases: GroupLikeInfo
Methods:
-
from_h5py_file–Return
FileInfofromh5py.Fileobject
from_h5py_file
classmethod
⚓︎
from_h5py_file(h5py_group: File) -> FileInfo
Return FileInfo from h5py.File object
could do with dict-comprehension, but not readable (imo)
datasets_and_groups = {
obj.name: H5Group.from_h5py_group(obj)
if isinstance(obj, Group)
else H5Dataset.from_h5py_dataset(obj)
for obj in h5py_group.values()
}
as_h5py_obj
⚓︎
as_h5py_obj(obj: File | Group | FsPath) -> File | Group
Convert a path or h5py object to an h5py object
attrs
⚓︎
Return a generator that yields tuples with: (HDF5-path, HDF5-attr)
attrs_dict
⚓︎
attrs_dict(
h5_obj: FsPath | File | Group, h5_path: str = ""
) -> dict[str, dict[str, str | NDArray[Any] | int | float]]
Load an HDF5 file from a fspath into a dictionary
Given a fspath this method loads an HDF5 file into a dictionary where the key => value pairs are the HDF5-path => HDF5-dataset for the file. This method relies on the h5_dataset_gen that is in this very module to generate tuples of the form (HDF5-path, HDF5-dataset).
Parameters:
-
(h5_obj⚓︎str) –Filepath to an HDF5 format file
-
(h5_path⚓︎str, default:'') –HDF5 path to recurse down from
Returns:
attrs_gen
⚓︎
attrs_gen(
h5_obj: FsPath | File | Group, h5_path: str = ""
) -> Iterable[tuple[str, AttributeManager]]
Return a generator that yields tuples with: (HDF5-path, HDF5-attr)
attrs_gen_from_fspath
⚓︎
attrs_gen_from_fspath(
fspath: FsPath, h5_path: str = ""
) -> Iterable[tuple[str, AttributeManager]]
datasets
⚓︎
Return a generator that yields tuples with: (HDF5-path, Dataset)
datasets_dict
⚓︎
datasets_dict(
h5_obj: FsPath | File | Group, h5_path: str = ""
) -> dict[str, NDArray[Any] | int8 | float64]
Load an HDF5 file from a fspath into a dictionary
Given a fspath this method loads an HDF5 file into a dictionary where the key => value pairs are the HDF5-path => HDF5-dataset for the file. This method relies on the h5_dataset_gen that is in this very module to generate tuples of the form (HDF5-path, HDF5-dataset).
Parameters:
-
(h5_obj⚓︎str) –Filepath to an HDF5 format file
-
(h5_path⚓︎str, default:'') –Path to start from. Defaults to "".
Returns:
datasets_gen
⚓︎
Return a generator that yields tuples with: (HDF5-path, Dataset)
datasets_gen_from_fspath
⚓︎
datasets_keys_list
⚓︎
fmt_h5_path
cached
⚓︎
Format function for HDF5-path-strings
Examples:
>>> fmt_h5_path("foo", "bar")
'/foo/bar'
groups
⚓︎
Return a generator that yields tuples with: (HDF5-path, h5py.Group)
groups_gen
⚓︎
Return a generator that yields tuples with: (HDF5-path, h5py.Group)
groups_gen_from_fspath
⚓︎
h5_attrs_dict
⚓︎
Alias for h5.attrs_dict
h5_attrs_gen
⚓︎
h5_attrs_gen(
h5_obj: FsPath | File | Group, h5_path: str = ""
) -> Iterable[tuple[str, AttributeManager]]
Alias for h5.datasets_gen
h5_attrs_gen_from_fspath
⚓︎
h5_attrs_gen_from_fspath(
fspath: FsPath, h5_path: str = ""
) -> Iterable[tuple[str, AttributeManager]]
h5_datasets_dict
⚓︎
Alias for h5.datasets_dict
h5_datasets_gen
⚓︎
h5_datasets_gen(
h5_obj: FsPath | File | Group, h5_path: str = ""
) -> Iterable[tuple[str, Dataset]]
Alias for h5.datasets_gen
h5_datasets_gen_from_fspath
⚓︎
h5py_obj_attrs_gen
⚓︎
h5py_obj_attrs_gen(
h5py_obj: File | Group,
h5_path: str = "",
*,
root: bool = True,
) -> Iterable[tuple[str, AttributeManager]]
h5py_obj_dataset_gen
⚓︎
Recursive h5 dataset generator.
Given an h5 group, which is what one gets after loading an h5 file via h5py, this function yields tuples containing (1.) a path (h5_path) to a dataset in the group, and (2.) the dataset itself as a numpy array.
Parameters:
-
(h5py_obj⚓︎File | Group) –h5-h5py group object
-
(h5_path⚓︎str, default:'') –path so far (Default value = "")
Returns:
h5py_obj_gen
⚓︎
h5py_obj_gen(
h5py_obj: File | Group,
h5_path: str = "",
*,
root: bool = True,
) -> Iterable[tuple[str, Dataset | Group | File]]
h5py_obj_groups_gen
⚓︎
h5py_obj_groups_gen(
h5py_obj: File | Group,
h5_path: str = "",
*,
root: bool = True,
) -> Iterable[tuple[str, Group]]
h5py_obj_keys_gen
⚓︎
h5py_obj_keys_gen(
h5py_obj: File | Group,
h5_path: str = "",
*,
root: bool = True,
) -> Iterable[str]