Hdf5Exportable
full name: tenpy.tools.hdf5_io.Hdf5Exportable
parent module:
tenpy.tools.hdf5_io
type: class
Inheritance Diagram
Methods
|
|
|
Load instance from a HDF5 file. |
|
Export self into a HDF5 file. |
- class tenpy.tools.hdf5_io.Hdf5Exportable[source]
Bases:
object
Interface specification for a class to be exportable to our HDF5 format.
To allow a class to be exported to HDF5 with
save_to_hdf5()
, it only needs to implement thesave_hdf5()
method as documented below. To allow import, a class should implement the classmethodfrom_hdf5()
. During the import, the class already needs to be defined; loading can only initialize instances, not define classes.The implementation given works for sufficiently simple (sub-)classes, for which all data is stored in
__dict__
. In particular, this works for python-defined classes which simply store data usingself.data = data
in their methods.- save_hdf5(hdf5_saver, h5gr, subpath)[source]
Export self into a HDF5 file.
This method saves all the data it needs to reconstruct self with
from_hdf5()
.This implementation saves the content of
__dict__
withsave_dict_content()
, storing the format under the attribute'format'
.
- classmethod from_hdf5(hdf5_loader, h5gr, subpath)[source]
Load instance from a HDF5 file.
This method reconstructs a class instance from the data saved with
save_hdf5()
.- Parameters:
hdf5_loader (
Hdf5Loader
) – Instance of the loading engine.h5gr (
Group
) – HDF5 group which is represent the object to be constructed.subpath (str) – The name of h5gr with a
'/'
in the end.
- Returns:
obj – Newly generated class instance containing the required data.
- Return type:
cls