8000 address FuncAnimantion trying to take lengths of generators by tacaswell · Pull Request #2634 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

address FuncAnimantion trying to take lengths of generators #2634

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

Merged
merged 4 commits into from
Jan 6, 2014
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added test for code path where the object passed into frames is
does not have a length.
  • Loading branch information
tacaswell committed Dec 12, 2013
commit 03c71f53cd8d1d39f4ef16687800ce07a3bea06b
19 changes: 19 additions & 0 deletions lib/matplotlib/tests/test_animation.py
8000
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@ def animate(i):
anim.save(F.name, fps=30, writer=writer)


@cleanup
def test_():
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)))

Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to des 5A3F cribe 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)
0