bagofholding.h5.triebag module
- class bagofholding.h5.triebag.TrieH5Bag(filepath: str | Path, *args: object, **kwargs: Any)[source]
Bases:
Bag,HasH5FileContext,ArrayPackerA bag using HDF5 files based on h5py.
Uses a trie structure to flatten the stored object. Compared to
bagofholding.h5.bag.H5Bag, this is advantageous for file sizes but (currently) has worse scaling for save times.The resulting HDF5 file cannot be directly related to the structure of the stored object, but must be re-mapped via mapping fields. Metadata is also lumped in with other string data to minimize the number of different h5 groups.
saveaccepts alibveroption (defaultmax_libver) controlling the HDF5 file-format version written, which is also stored in the bag info. Only codes up tomax_libverare accepted;"latest"is not.- get_bespoke_content_class(obj: object) type[BespokeItem[Any, Self]] | None[source]
- 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]
- min_compatible_version: ClassVar[str | None] = '0.1.9'
The oldest bagofholding version whose saved bags this class can read.
- 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]
- 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]
- property unpacked_trie: StringTrie