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
address FuncAnimantion trying to take lengths of generators #2634
Changes from all commits
b57c6dc
03c71f5
8ab1f0a
1b144e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,25 @@ def animate(i): | |
anim.save(F.name, fps=30, writer=writer) | ||
|
||
|
||
@cleanup | ||
def test_no_length_frames(): | ||
fig, ax = plt.subplots() | ||
line, = ax.plot([], []) | ||
|
||
def init(): | ||
line.set_data([], []) | ||
return line, | ||
|
||
def animate(i): | ||
x = np.linspace(0, 10, 100) | ||
y = np.sin(x + i) | ||
line.set_data(x, y) | ||
return line, | ||
|
||
anim = animation.FuncAnimation(fig, animate, init_func=init, | ||
frames=iter(range(5))) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should there be an assertion here? I appreciate the fact that you're calling the constructor, and that before it was raising an Exception, but it'd be nice to test the attributes which you expect to have been set. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given the discussion above about the value it defaults to and my confusion of what this value actually does (does it make sense to keep a rolling buffer of an infinite generator?) I think it is better to just test 'does it blow up' here due to the high chance of what it defaults to changing in the (near) future. |
||
|
||
if __name__ == "__main__": | ||
import nose | ||
nose.runmodule(argv=['-s', '--with-doctest'], exit=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if
save_count
isn't set. Is this a problem?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. Urgh, it defaults to
100
. Perhaps we are better assuming that the generator isn't infinite and casting it to a list?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why that is a problem, it will just keep a rolling buffer of that length. It isn't useful, but it's not really harmful. I might also be confused.
I think it is important to keep the ability to have infinite generators, this is a quick way to spin up realtime-ish diagnostic displays.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes, thanks @tacaswell - I misunderstood what thee save count was doing. Ignore me 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That said, I have never figured out where the saved frames are used....
I am not sure if it is precursor work for a feature that never got finished or I just don't understand what it is doing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tacaswell - I think we should try to add a test case (hopefully it will be quite straight forward) which exercises this code path.