CallbackStore¶
-
class
odl.solvers.util.callback.
CallbackStore
(results=None, function=None, step=1)[source]¶ Bases:
odl.solvers.util.callback.Callback
Callback for storing all iterates of a solver.
Can optionally apply a function, for example the norm or calculating the residual.
By default, calls the
copy()
method on the iterates before storing.Methods
reset
(self)Clear the results list.
-
__init__
(self, results=None, function=None, step=1)[source]¶ Initialize a new instance.
- Parameters
- resultslist, optional
List in which to store the iterates. Default: new list (
[]
)- functioncallable, optional
Deprecated, use composition instead. See examples. Function to be called on all incoming results before storage. Default: copy
- stepint, optional
Number of iterates between storing iterates.
Examples
Store results as-is:
>>> callback = CallbackStore()
Provide list to store iterates in:
>>> results = [] >>> callback = CallbackStore(results=results)
Store the norm of the results:
>>> norm_function = lambda x: x.norm() >>> callback = CallbackStore() * norm_function
-