load_from_hdf5

  • full name: tenpy.tools.hdf5_io.load_from_hdf5

  • parent module: tenpy.tools.hdf5_io

  • type: function

tenpy.tools.hdf5_io.load_from_hdf5(h5group, path=None, ignore_unknown=True, exclude=None)[source]

Load an object from hdf5 file or group.

Roughly equivalent to obj = h5group[path][...], but handle more complicated objects saved as hdf5 groups and/or datasets with save_to_hdf5(). For example, dictionaries are handled recursively. See Saving to disk: input/output for a specification of what can be saved/loaded and what the corresponding datastructure is.

Parameters:
  • h5group (Group) – The HDF5 group (or h5py File) to be loaded.

  • path (None | str | Reference) – Path within h5group to be used for loading. Defaults to the h5group itself specified.

  • ignore_unknown (bool) – Whether to just warn (True) or raise an Error (False) if a class to be loaded is not found.

  • exclude (list of str) – List of paths (possibly relative to h5group) for objects to be excluded from loading. References to the corresponding object are replaced by an instance of Hdf5Ignored. For example, you could load a saved dictionary {'big_data': [...], 'small_data': small_data} with exclude=['/big_data'] to get {'big_data': Hdf5Ignored('/big_data'), 'small_data': small_data}. Of course, this might break other functions expecting correctly loaded data.

Returns:

obj – The Python object loaded from h5group (specified by path).

Return type:

object