CallbackShow¶
-
class
odl.solvers.util.callback.
CallbackShow
(title=None, step=1, saveto=None, **kwargs)[source]¶ Bases:
odl.solvers.util.callback.Callback
Callback for showing iterates.
Methods
reset
(self)Set
iter
to 0 and create a new figure.-
__init__
(self, title=None, step=1, saveto=None, \*\*kwargs)[source]¶ Initialize a new instance.
Additional parameters are passed through to the
show
method.- Parameters
- titlestr, optional
Format string for the title of the displayed figure. The title name is generated as
title = title.format(cur_iter_num)
where
cur_iter_num
is the current iteration number. For the defaultNone
, the title format'Iterate {}'
is used.- steppositive int, optional
Number of iterations between plots.
- savetostr or callable, optional
Format string for the name of the file(s) where iterates are saved.
If
saveto
is a string, the file name is generated asfilename = saveto.format(cur_iter_num)
where
cur_iter_num
is the current iteration number.If
saveto
is a callable, the file name is generated asfilename = saveto(cur_iter_num)
If the directory name does not exist, a
ValueError
is raised. Ifsaveto is None
, the figures are not saved.
- Other Parameters
- kwargs :
Optional keyword arguments passed on to
x.show
.
Examples
Show the result of each iterate:
>>> callback = CallbackShow()
Show and save every fifth iterate in
png
format, overwriting the previous one:>>> callback = CallbackShow(step=5, ... saveto='my_path/my_iterate.png')
Show and save each fifth iterate in
png
format, indexing the files with the iteration number:>>> callback = CallbackShow(step=5, ... saveto='my_path/my_iterate_{}.png')
Pass additional arguments to
show
:>>> callback = CallbackShow(step=5, clim=[0, 1])
-