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
–h5py mode strings (taken from h5py docstrings)):
H5pyCompression
module-attribute
⚓︎
H5pyCompression = Literal['gzip', 'lzf', 'szip']
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
–could do with dict-comprehension, but not readable (imo)
as_h5py_obj
⚓︎
as_h5py_obj(obj: T_FsPathOrGroupLike) -> Union[File, Group]
Convert a path or h5py object to an h5py object
attrs
⚓︎
attrs(
h5_obj: Union[FsPath, File, Group], h5_path: str = ""
) -> Iterable[Tuple[str, AttributeManager]]
Return a generator that yields tuples with: (HDF5-path, HDF5-attr)
attrs_dict
⚓︎
attrs_dict(
h5_obj: Union[FsPath, File, Group], h5_path: str = ""
) -> Dict[
str, Dict[str, Union[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: Union[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: Union[FsPath, File, Group], h5_path: str = ""
) -> Dict[str, Union[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
⚓︎
datasets_gen(
h5_obj: Union[FsPath, File, Group], h5_path: str = ""
) -> Iterable[Tuple[str, Dataset]]
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
Example
fmt_h5_path("foo", "bar") '/foo/bar'
groups
⚓︎
groups(
h5_obj: Union[FsPath, File, Group], h5_path: str = ""
) -> Iterable[Tuple[str, AttributeManager]]
Return a generator that yields tuples with: (HDF5-path, h5py.Group)
groups_gen
⚓︎
groups_gen(
h5_obj: Union[FsPath, File, Group], h5_path: str = ""
) -> Iterable[Tuple[str, AttributeManager]]
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: Union[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: Union[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: Union[File, Group],
h5_path: str = "",
root: bool = True,
) -> Iterable[Tuple[str, AttributeManager]]
h5py_obj_dataset_gen
⚓︎
h5py_obj_dataset_gen(
h5py_obj: Union[File, Group], h5_path: str = ""
) -> Iterable[Tuple[str, Dataset]]
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
⚓︎Union[File, Group]
) –h5-h5py group object
-
h5_path
⚓︎str
, default:''
) –path so far (Default value = "")
Returns:
h5py_obj_gen
⚓︎
h5py_obj_gen(
h5py_obj: Union[File, Group],
h5_path: str = "",
root: bool = True,
) -> Iterable[Tuple[str, Union[Dataset, Group, File]]]
h5py_obj_groups_gen
⚓︎
h5py_obj_groups_gen(
h5py_obj: Union[File, Group],
h5_path: str = "",
root: bool = True,
) -> Iterable[Tuple[str, Group]]
h5py_obj_keys_gen
⚓︎
h5py_obj_keys_gen(
h5py_obj: Union[File, Group],
h5_path: str = "",
root: bool = True,
) -> Iterable[str]