Hdf5Loader¶
full name: tenpy.tools.hdf5_io.Hdf5Loader
parent module:
tenpy.tools.hdf5_io
type: class
Inheritance Diagram
Methods
|
Initialize self. |
|
Get the class of the qualified classname in a given python module. |
|
Return attribute |
|
Load a Python |
|
Load a h5py |
|
Load a dictionary in the format according to type_info. |
|
Load a |
|
Load a dictionary with general keys. |
|
Load an instance of a userdefined class. |
|
Ignore the group to be loaded. |
|
Load a list. |
|
Load the |
|
Load a range. |
|
Load a set. |
|
Load a dictionary with simple keys. |
|
Load a tuple. |
|
Store objects already loaded in the |
Class Attributes and Properties
-
class
tenpy.tools.hdf5_io.
Hdf5Loader
(h5group, ignore_unknown=True)[source]¶ Bases:
object
Class to load and import object from a HDF5 file.
The intended use of this class is through
load_from_hdf5()
, which is simply an alias forHdf5Loader(h5group).load(path)
.It can load data exported with
save_to_hdf5()
or theHdf5Saver
, respectively.The basic structure of this class is similar as the Unpickler from
pickle
.See Saving to disk: input/output for a specification of what can be saved and what the resulting datastructure is.
- Parameters
-
ignore_unknown
¶ Whether to just warn (True) or raise an Error (False) if a class to be loaded is not found.
- Type
-
dispatch_load
¶ Mapping from one of the global
REPR_*
variables to (unbound) methods f of this class. The method is called asf(self, h5gr, type_info, subpath)
. The call to f should load and return an object obj from the h5pyGroup
orDataset
h5gr; and memorize the loaded obj withmemorize_load()
. subpath is just the name of h5gr with a guaranteed'/'
in the end. type_info is often theREPR_*
variable of the type or some other information about the type, which allows to use a single dispatch_load function for different datatypes.- Type
-
memo_load
¶ A dictionary to remember all the objects which we already loaded from
h5group
. The dictionary key is a h5py group- or datasetid
; the value is the loaded object. Seememorize_load()
.- Type
-
load
(path=None)[source]¶ Load a Python
object
from the dataset.See
load_from_hdf5()
for more details.
-
memorize_load
(h5gr, obj)[source]¶ Store objects already loaded in the
memo_load
.This allows to avoid copies, if the same dataset appears multiple times in the hdf5 group of obj. Examples can be shared
LegCharge
objects or even sharedArray
.To handle cyclic references correctly, this function should be called before loading data from subgroups with new calls of
load()
.
-
static
get_attr
(h5gr, attr_name)[source]¶ Return attribute
h5gr.attrs[attr_name]
, if existent.- Raises
Hdf5ImportError – If the attribute does not exist.
-
static
find_class
(module, classname)[source]¶ Get the class of the qualified classname in a given python module.
Imports the module.
-
load_dataset
(h5gr, type_info, subpath)[source]¶ Load a h5py
Dataset
and convert it into the desired type.
-
load_dict
(h5gr, type_info, subpath)[source]¶ Load a dictionary in the format according to type_info.
-
load_dtype
(h5gr, type_info, subpath)[source]¶ Load a
numpy.dtype
.