Hdf5Storage
full name: tenpy.tools.cache.Hdf5Storage
parent module:
tenpy.tools.cache
type: class
Inheritance Diagram
Methods
|
|
Close opened files, free memory and clean up temporary files/directories. |
|
|
Interface for cleaning up a previously saved data from disk in subclasses. |
|
Interface for loading data from disk in subclasses. |
|
Create an hdf5 file and use it to initialize an |
|
Interface for preloading data into the given dictionary into. |
|
Interface for saving data to disk in subclasses. |
|
Create another instance of the same class saving in a subdirectory/subgroup. |
Class Attributes and Properties
Whether the storage is actually kept in memory, instead of saving to disk. |
- class tenpy.tools.cache.Hdf5Storage(h5group)[source]
Bases:
Storage
Subclass of
Storage
which saves long-term data on disk withh5py
.Warning
Some benchmarks that I ran when implementing this indicate that
PickleStorage
has a much lower overhead than theHdf5Storage
. Unless you have benchmarks indicated the opposite, I highly recommend sticking toPickleStorage
.- Parameters:
h5group (
Group
) – The hdf5 group in which data will be saved usingsave_to_hdf5()
under the specified keys.
- trivial = False
Whether the storage is actually kept in memory, instead of saving to disk.
- classmethod open(filename=None, subgroup=None, mode='w-', delete=True, tmpdir=None)[source]
Create an hdf5 file and use it to initialize an
Hdf5Cache
.- Parameters:
filename (path-like | None) – Filename of the Hdf5 file to be created. If None, create a temporary file with
tempfile
tools.tmpdir (path-like | None) – Only used if filename is None. Used as base dir for
tempfile.mkdtemp()
, i.e., a temporary directory is created within this path, and inside that the hdf5 file.mode (str) – Filemode for opening the Hdf5 file.
delete (bool) – Whether to automatically remove the corresponding file when closing the cache.
- subcontainer(name)[source]
Create another instance of the same class saving in a subdirectory/subgroup.
This method allows multiple
DictCache
instance re-using open resources. Subcontainers will explicitly be closed when any of the parent containers (on which subcontainer() was called) is closed.
- preload(key)[source]
Interface for preloading data into the given dictionary into.
Only overridden in
ThreadedStorage
for thread-parallelized pre-loading; in other cases it does nothing.