bagofholding.h5.bag module

class bagofholding.h5.bag.H5Bag(filepath: str | Path, *args: object, **kwargs: Any)[source]

Bases: Bag, HasH5FileContext, ArrayPacker

A bag using HDF5 files based on h5py.

The underlying file structure is directly representative of the structure of the decomposed object being stored, and attrs are used to store metadata.

save accepts a libver option (default max_libver) controlling the HDF5 file-format version written, which is also stored in the bag info. Only codes up to max_libver are accepted; "latest" is not.

create_group(path: str) → None[source]
classmethod get_bag_info() → BagInfo[source]
get_bespoke_content_class(obj: object) → type[BespokeItem[Any, Self]] | None[source]
list_paths() → list[str][source]

A list of all available content paths.

load(path: str = 'object', version_validator: Literal['exact', 'semantic-patch', 'semantic-minor', 'semantic-major', 'none'] | Callable[[str, str], bool] = 'exact', version_scraping: dict[str, Callable[[str], str | None]] | None = None) → Any[source]
open_group(path: str) → list[str][source]
pack_array(obj: ndarray[tuple[int, ...], dtype[int8] | dtype[int16] | dtype[int32] | dtype[int64] | dtype[uint8] | dtype[uint16] | dtype[uint32] | dtype[uint64] | dtype[float16] | dtype[float32] | dtype[float64] | dtype[complex64] | dtype[complex128] | dtype[bool] | dtype[bytes_] | dtype[str_]], path: str) → None[source]
pack_bool(obj: bool, path: str) → None[source]
pack_bytearray(obj: bytearray, path: str) → None[source]
pack_bytes(obj: bytes, path: str) → None[source]
pack_complex(obj: complex, path: str) → None[source]
pack_empty(path: str) → None[source]
pack_float(obj: float, path: str) → None[source]
pack_long(obj: int, path: str) → None[source]
pack_string(obj: str, path: str) → None[source]
unpack_array(path: str) → ndarray[tuple[int, ...], dtype[int8] | dtype[int16] | dtype[int32] | dtype[int64] | dtype[uint8] | dtype[uint16] | dtype[uint32] | dtype[uint64] | dtype[float16] | dtype[float32] | dtype[float64] | dtype[complex64] | dtype[complex128] | dtype[bool] | dtype[bytes_] | dtype[str_]][source]
unpack_bool(path: str) → bool[source]
unpack_bytearray(path: str) → bytearray[source]
unpack_bytes(path: str) → bytes[source]
unpack_complex(path: str) → complex[source]
unpack_float(path: str) → float[source]
unpack_long(path: str) → int[source]
unpack_string(path: str) → str[source]
class bagofholding.h5.bag.H5Info(qualname: 'str | None' = None, module: 'str | None' = None, version: 'str | None' = None, libver_str: 'str | None' = 'latest')[source]

Bases: BagInfo

libver_str: str | None = 'latest'