Documentation¶
This module contains functions to save and load objects, using the HDF5 format.
-
fsc.hdf5_io.
save
(obj, hdf5_file)¶ Alias for
to_hdf5_file()
.
-
fsc.hdf5_io.
load
(hdf5_file)¶ Alias for
from_hdf5_file()
.
-
fsc.hdf5_io.
from_hdf5
(hdf5_handle)[source]¶ Deserializes the given HDF5 handle into an object.
Parameters: hdf5_handle ( h5py.File
orh5py.Group
.) – HDF5 location where the serialized object is stored.
-
fsc.hdf5_io.
to_hdf5
(obj, hdf5_handle)[source]¶ Serializes a given object to HDF5 format.
Parameters: - obj – Object to serialize.
- hdf5_handle (
h5py.File
orh5py.Group
.) – HDF5 location where the serialized object gets stored.
-
fsc.hdf5_io.
to_hdf5_singledispatch
(obj, hdf5_handle)[source]¶ Singledispatch function which is called to serialize and object when it does not have a
to_hdf5
method.Parameters: - obj – Object to serialize.
- hdf5_handle (
h5py.File
orh5py.Group
.) – HDF5 location where the serialized object gets stored.
-
fsc.hdf5_io.
from_hdf5_file
(hdf5_file)[source]¶ Alias for
from_hdf5_file()
.
-
fsc.hdf5_io.
to_hdf5_file
(obj, hdf5_file)[source]¶ Alias for
to_hdf5_file()
.
-
class
fsc.hdf5_io.
HDF5Enabled
[source]¶ Base class for data which can be serialized to and deserialized from HDF5.
-
fsc.hdf5_io.
subscribe_hdf5
(type_tag, extra_tags=(), check_on_load=True)[source]¶ Class decorator that subscribes the class with the given type_tag for serialization.
Parameters: - type_tag (str) – Unique identifier of the class, which is injected into the HDF5 data to identify the class.
- extra_tags (tuple(str)) – Additional tags which should be deserialized to the given class.
- check_on_load (bool) – Flag that determines whether the ‘type_tag’ is checked when de-serializing the object.
-
class
fsc.hdf5_io.
SimpleHDF5Mapping
[source]¶ Base class for data classes which simply map their member to HDF5 values / groups.
The child class needs to define a list
HDF5_ATTRIBUTES
of attributes which should be serialized. The name of the attributes must correspond to the name accepted by the constructor.