-
Notifications
You must be signed in to change notification settings - Fork 85
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
fix: Use non-gui matplotlib backend for tests to avoid hanging on ipywidgets interact #2098
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Codecov ReportBase: 98.30% // Head: 98.30% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## main #2098 +/- ##
=======================================
Coverage 98.30% 98.30%
=======================================
Files 69 69
Lines 4531 4531
Branches 645 645
=======================================
Hits 4454 4454
Misses 45 45
Partials 32 32
Flags with carried forward coverage won't be shown. Click here to find out more. Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Bug reproducible with $ jupyter execute docs/examples/notebooks/learn/InterpolationCodes.ipynb
[NbClientApp] Executing docs/examples/notebooks/learn/InterpolationCodes.ipynb
[NbClientApp] Executing notebook with kernel: python3 which then hangs. |
Freezing on the from ipywidgets import interact ... x = interact(
lambda alpha: plot_interpolated_histogram(alpha, down_hist, nom_hist, up_hist),
alpha=(-1, 1, 0.1),
) of https://github.com/scikit-hep/pyhf/blob/3eef1fff2e6d4ccf474bbe51e2211cf690752b82/docs/examples/notebooks/learn/InterpolationCodes.ipynb for |
Seems to be a general problem with interact https://ipywidgets.readthedocs.io/en/8.0.2/examples/Using%20Interact.html as
|
Temporary workaround locally: $ jupytext --to py:percent docs/examples/notebooks/learn/InterpolationCodes.ipynb
[jupytext] Reading docs/examples/notebooks/learn/InterpolationCodes.ipynb in format ipynb
[jupytext] Updating the timestamp of docs/examples/notebooks/learn/InterpolationCodes.py
$ MPLBACKEND=agg python docs/examples/notebooks/learn/InterpolationCodes.py
interactive(children=(FloatSlider(value=0.0, description='alpha', max=1.0, min=-1.0), Output()), _dom_classes=('widget-interact',))
[[ 8. 8.2 8.4 8.6 8.8 9. 9.2 9.4 9.6 9.8 10. ]]
[[10. 10.3 10.6 10.9 11.2 11.5 11.8 12.1 12.4 12.7 13. ]]
[[15. 15.5 16. 16.5 17. 17.5 18. 18.5 19. 19.5 20. ]]
/home/feickert/Code/GitHub/pyhf/docs/examples/notebooks/learn/InterpolationCodes.py:221: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
plt.show()
interactive(children=(FloatSlider(value=0.0, description='alpha', max=1.0, min=-1.0), Output()), _dom_classes=('widget-interact',)) also just $ MPLBACKEND=agg jupyter execute docs/examples/notebooks/learn/InterpolationCodes.ipynb
[NbClientApp] Executing docs/examples/notebooks/learn/InterpolationCodes.ipynb
[NbClientApp] Executing notebook with kernel: python3 |
* pylab has been deprecated a long time and including it causes runtime problems
21fd150
to
03106eb
Compare
Description
ipywidgets
interact
sections ofInterpolationCodes.ipynb
set the matplotlib backend to the non-gui Agg which disallows the creation of the gui elements that are causing the problem. This also speeds up runtime as no gui-elements are created for the notebook tests now.Checklist Before Requesting Reviewer
Before Merging
For the PR Assignees: