-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
func animation warning changes #11829
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
func animation warning changes #11829
Conversation
Well spotted, @fredrik-1. I do however fear that people might not understand the motivation and implication. So the following code works fine on 2.2.2
Due to a change in #11370 the same code now breaks in master with
This is due to the animating function not returning an iterable of artists. According to the documentation such animating function should indeed return an iterable of artists, however there is in principle no such need if If a version with #11370 in is now being released, it will break a lot of people's codes. Options:
I would consider this release critical for 3.0. |
For 3.0 this fix is the pragmatic change to prevent back-compatibility issues. For 3.1 we may want to start warning if no artists are returned, but that should happen in a different PR. |
although it is a bit questionable why one would force users to add some useless line like
just to prevent some warning. |
Until I finally finish refactoring the blitting code so that it's more reliable, I think it's fine to only care about having the callback return artists for the blitting path. |
As say this as someone who just spent the last month writing a library that wraps funcanimation. It is a really bad idea to require that the callback has returns artists (if blitting is false). My library is built on the concept "blocks" while most of my blocks return artists some don't. (which means I might return a list of artists with some NoneTypes though I can issue a warning if blitting is true and certain blocks are used) Animating things in matplotlib can be very difficult. It is very common for people to do: def animate(i):
ax.clear()
#re-plot everything This is a common tactic for pcolormesh despite there being a proper way to update the data, and for some types of plots (like pie charts), it's the only reasonably easy way. Requiring it to return artists just make's it a lot harder for people. I'm seriously against requiring the callback to return artists in the future (if blitting is false). Totally for an error if blit is true. |
So that seems to be pretty conclusive that we do not want to start warning on no returns for 3.1 ! |
Another pr from #11792
The example code on that issue raised on error on master but not on v2.2.2. The reason where that the animation function returned None.
This pr change the order of some of the code to avoid the error and just test for the return value when it is needed when
blit
is True.I am not sure if this is necessary or if the test is in the right place but the behavior is better now than before.
The animation function should return an iterative according to the documentation but I think that it is unnecessary to test for it and raise on error or warning when it is not necessary for the code to work.