pyiron_base.interfaces.has_dict.HasDictfromHDF#
- class pyiron_base.interfaces.has_dict.HasDictfromHDF[source]#
-
Implements HasDict in terms of HasHDF.
This class is intended for “old-style” objects that should be able to be used as children for objects that already implement HasDict and expect their children to implmement it.
- __init__()#
Methods
__init__()from_dict(obj_dict[, version])Populate the object from the serialized object.
from_hdf(hdf[, group_name])Read object to HDF.
from_hdf_args(hdf)Read arguments for instance creation from HDF5 file.
instantiate(obj_dict[, version])Create a blank instance of this class.
rewrite_hdf(hdf[, group_name])Update the HDF representation.
to_dict()Reduce the object to a dictionary.
to_hdf(hdf[, group_name])Write object to HDF.
- from_dict(obj_dict: dict, version: str = None)#
Populate the object from the serialized object.
- Parameters:
obj_dict (dict) – data previously returned from
to_dict()version (str) – version tag written together with the data
- from_hdf(hdf: ProjectHDFio, group_name: str = None)#
Read object to HDF.
If group_name is given descend into subgroup in hdf first.
- Parameters:
hdf (
ProjectHDFio) – HDF group to read fromgroup_name (str, optional) – name of subgroup
- classmethod from_hdf_args(hdf: ProjectHDFio) dict#
Read arguments for instance creation from HDF5 file.
- Parameters:
hdf (ProjectHDFio) – HDF5 group object
- Returns:
arguments that can be **kwarg-passed to cls().
- Return type:
dict
- classmethod instantiate(obj_dict: dict, version: str = None) Self[source]#
Create a blank instance of this class.
This can be used when some values are already necessary for the objects __init__.
- Parameters:
obj_dict (dict) – data previously returned from
to_dict()version (str) – version tag written together with the data
- Returns:
a blank instance of the object that is sufficiently initialized to call
_from_dict()on it- Return type:
object
- rewrite_hdf(hdf: ProjectHDFio, group_name: str = None)#
Update the HDF representation.
If an object is read from an older layout, this will remove the old data and rewrite it in the newest layout.
- Parameters:
hdf (
ProjectHDFio) – HDF group to read/writegroup_name (str, optional) – name of subgroup
- to_dict() dict#
Reduce the object to a dictionary.
- Returns:
serialized state of this object
- Return type:
dict
- to_hdf(hdf: ProjectHDFio, group_name: str = None)#
Write object to HDF.
If group_name is given create a subgroup in hdf first.
- Parameters:
hdf (
ProjectHDFio) – HDF group to write togroup_name (str, optional) – name of subgroup