Callbacks¶
- class ionworkspipeline.callbacks.Callback¶
Base class for callbacks, for documenting callback methods.
Callbacks are used to perform actions (e.g. logging, saving) at certain points in the simulation. Each callback method is named on_<event>, where <event> describes the point at which the callback is called. For example, the callback on_datafit_finish is called at the end of a data fit. In general, callbacks take a single argument, logs, which is a dictionary of information about the simulation. Each callback method should return None (the output of the method is ignored).
- on_datafit_finish(logs)¶
Called at the end of the DataFit.
Objectives in the ionworkspipeline library will pass logs containing
“inputs”: the current values of the parameters (dict)
- “outputs”: the current values of the variables, including but not limited to
those used in the objective (dict)
Custom objective may pass different logs.
- on_datafit_start(logs)¶
Called at the start of the DataFit.
Objectives in the ionworkspipeline library will pass logs containing
“inputs”: the current values of the parameters (dict)
- “outputs”: the current values of the variables, including but not limited to
those used in the objective (dict)
Custom objective may pass different logs.
- on_objective_build(logs)¶
Called after the objective has been set up.
Objectives in the ionworkspipeline library will pass logs containing
“options”: the options to be used in the data fit (dict)
- “data”: the variables in the data, including but not limited to those used in
the objective (dict)
Custom objective may pass different logs.
- on_run_iteration(logs)¶
Called at each iteration of evaluating the objective.
Objectives in the ionworkspipeline library will pass logs containing
“inputs”: the current values of the parameters (dict)
- “outputs”: the current values of the variables, including but not limited to
those used in the objective (dict)
Custom objective may pass different logs.
- plot_fit_results()¶
Plot fit results. For internal callbacks, this method is called by
DataFit.plot_fit_results()
. For external callbacks, the user should implement and call their own plotting method.
- class ionworkspipeline.callbacks.SaveResultsCallback(folder=None)¶
Callback to save the initial and final results of a data fit. Initial results are saved to the initial_results_ attribute when on_datafit_start is called, and final results are saved to the fit_results_ attribute when on_datafit_finish is called.
Most of the inbuilt callbacks in the ionworkspipeline library use this callback as the parent class, then add object-specific functionality (e.g. plotting).
Parameters¶
- folderstr, optional
If provided, results are saved to this folder
Extends:
ionworkspipeline.data_fits.callbacks.Callback
- property all_results¶
Return all results in a dictionary
- on_datafit_finish(logs)¶
Called at the end of the DataFit.
Objectives in the ionworkspipeline library will pass logs containing
“inputs”: the current values of the parameters (dict)
- “outputs”: the current values of the variables, including but not limited to
those used in the objective (dict)
Custom objective may pass different logs.
- on_datafit_start(logs)¶
Called at the start of the DataFit.
Objectives in the ionworkspipeline library will pass logs containing
“inputs”: the current values of the parameters (dict)
- “outputs”: the current values of the variables, including but not limited to
those used in the objective (dict)
Custom objective may pass different logs.
- on_objective_build(logs)¶
Called after the objective has been set up.
Objectives in the ionworkspipeline library will pass logs containing
“options”: the options to be used in the data fit (dict)
- “data”: the variables in the data, including but not limited to those used in
the objective (dict)
Custom objective may pass different logs.