CallbackShow
- class odl.solvers.util.callback.CallbackShow(title=None, step=1, saveto=None, **kwargs)[source]
Bases:
CallbackCallback for showing iterates.
See Also
odl.core.discr.discr_space.DiscretizedSpaceElement.show odl.core.space.base_tensors.Tensor.show
- __init__(title=None, step=1, saveto=None, **kwargs)[source]
Initialize a new instance.
Additional parameters are passed through to the
showmethod.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_numis 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
savetois a string, the file name is generated asfilename = saveto.format(cur_iter_num)
where
cur_iter_numis the current iteration number.If
savetois a callable, the file name is generated asfilename = saveto(cur_iter_num)
If the directory name does not exist, a
ValueErroris 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
pngformat, overwriting the previous one:>>> callback = CallbackShow(step=5, ... saveto='my_path/my_iterate.png')
Show and save each fifth iterate in
pngformat, 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])