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
[Bug]: Swallowed error in Jupyter+Matplotlib FuncAnimation. #27822
Comments
I think you need to trigger the animation to render. You can do this directly with On my system, |
I suspect this is related to the issue with event callbacks where any |
Yeah, but with the default settings, if you just remove the I also confirm that by adding a write to a file and this is triggered.
Hum that seem more likely, I didn't tracked if the is an try/except in this stack and if it would print anything. I'll see if I can track that down. |
@Carreau I can reproduce your behavior that it auto-displays properly with the assert removed but we get just a normal repr if the assertion is present. Weird. None of this makes sense, because the auto-display AFAICT is going through def _repr_html_(self):
"""IPython display hook for rendering."""
fmt = mpl.rcParams['animation.html']
if fmt == 'html5':
return self.to_html5_video()
elif fmt == 'jshtml':
return self.to_jshtml() and I can get the assertion output from both methods called in there. |
Bug summary
In some case it seem that FuncAnimation in Jupyter + matplotlib widgets + funcanimation just swallow error, leading to hard to debug error as to why animations don't show.
Code for reproduction
Here is a dumb animation where the animate part, raise an error (in the original code this was a typo so a NameError, but for readability, here an assert).
Actual outcome
Animation not happening
Expected outcome
Show at least a warnings that the animate function raised
Additional information
I tried to print a trace as to when the animate function get called see
https://gist.github.com/Carreau/e6510855ecab88630f1ea5985a98358c
This is likely multiple problems, matpltolib may want have an explicit warning that animate crash, but ipympl, comm, and ipykernel itself should likely have error messages as well.
Operating system
osx
Matplotlib Version
3.8.3
Matplotlib Backend
module://ipympl.backend_nbagg
Python version
3.11
Jupyter version
4.0.9
Installation
pip
The text was updated successfully, but these errors were encountered: