-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with using callback to show intermediate results in iterative solvers #1636
Comments
I think this is just a problem with |
So, this particular issue is indeed easily fixed by --- a/odl/util/graphics.py
+++ b/odl/util/graphics.py
@@ -436,14 +436,13 @@ def show_discrete_data(values, grid, title=None, method='',
plt.colorbar(mappable=csub, ticks=ticks, format=fmt)
elif update_in_place:
# If it exists and we should update it
- csub.colorbar.set_clim(minval, maxval)
+ csub.set_clim(minval, maxval)
csub.colorbar.set_ticks(ticks)
if '%' not in fmt:
labels = [fmt] * len(ticks)
else: There is then another error a few lines down:
--- a/odl/util/graphics.py
+++ b/odl/util/graphics.py
@@ -443,7 +443,7 @@ def show_discrete_data(values, grid, title=None, method='',
else:
labels = [fmt % t for t in ticks]
csub.colorbar.set_ticklabels(labels)
- csub.colorbar.draw_all()
+ fig.draw_without_rendering()
# Set title of window
if title is not None: This does not work right though: all axis labels and also the colorbar itself vanish.
Correction: actually the colorbar is not updated without the line. |
The update methods for colorbars have been removed in favour of more global updates. Applying the change to the `clim`s simply on the `csub` was suggested by paulhausner in odlgroup#1635 and seems to work fine. Actually updating the drawing of the colorbar (specifically, the ticks on it) did not work with the fix suggested in the Matplotlib documentation, but `canvas.draw_idle()` does seem to have the intended effect. Fixes odlgroup#1636.
The update methods for colorbars have been removed in favour of more global updates. Applying the change to the `clim`s simply on the `csub` was suggested by paulhausner in #1635 and seems to work fine. Actually updating the drawing of the colorbar (specifically, the ticks on it) did not work with the fix suggested in the Matplotlib documentation, but `canvas.draw_idle()` does seem to have the intended effect. Fixes #1636.
Most solvers in ODL are iterative and my understanding is that setting a callback offers a way to pass instructions to such a solver that can be executed in each iterate. There now seems to be an issue with the way the callback-function in ODL interfaces with the show-function. More specifically, one can use callback to show intermediate reconstructions in each iterate by setting
callback_settings = (odl.solvers.CallbackPrintIteration() & odl.solvers.CallbackShow())
and then calling the ODL solver with
callback=callback_settings
. However, this yields an attribute error that allow the first iterate to be shown, but then iterates are terminated with the messageBelow is a small example demonstrating the issue.
The text was updated successfully, but these errors were encountered: