netket.utils.history.HistoryDict#
- class netket.utils.history.HistoryDict[source]#
Bases:
objectA class that behaves like a dictionary, mapping strings to History instances or nested HistoryDict instances.
This class behaves to all effects as a dictionary at runtime, but it allows us to specify custom serialization and deserialization routines, which are used to save and load the data.
Note
This class can be used to deserialize a dictionary of histories, such as the standard log files obtained from
RuntimeLogandJsonLog.Warning
This class should not be constructed directly. Instead, use
accum_histories_in_tree()to build complex nested history structures, or create instances throughRuntimeLogfor logging purposes.- Inheritance

- __init__(*args, **kwargs)[source]#
Create a new HistoryDict instance from a dictionary of histories.
- Methods
- classmethod from_file(fname)[source]#
Create an HistoryDict from a text-file containing its serialization.
- Parameters:
fname (
str) – The name of the file to read.- Return type:
Self
- get(key, default=None)[source]#
Get a value from the dictionary, with a default value if the key is not present.
If the value is a dictionary, it is wrapped in a HistoryDict instance.
- Parameters:
key (
str) – The key to retrieve.default – The default value to return if the key is not present.
- push(value, step=None)[source]#
Accumulate a new data point into this HistoryDict.
Updates the history by appending the values in
valueat the givenstep. Keys present invaluebut not yet in this HistoryDict are added automatically; keys present in this HistoryDict but absent fromvalueare left unchanged (sparse logging is supported).- Parameters:
value – A (nested) dictionary whose leaves are the new scalar or array values to record.
step (
int|None) – The iteration index associated with this data point. IfNone(the default), it is set to one past the last step recorded in any leaf history (0for an empty HistoryDict), yielding an auto-incrementing index0, 1, 2, ...that also resumes correctly after an explicitstep.
- Return type:
- Returns:
An updated
HistoryDictwith the new data appended.