MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_animation_frame

Function test_animation_frame

lib/matplotlib/tests/test_animation.py:444–473  ·  view source on GitHub ↗
(tmp_path, fig_test, fig_ref)

Source from the content-addressed store, hash-verified

442
443@check_figures_equal()
444def test_animation_frame(tmp_path, fig_test, fig_ref):
445 # Test the expected image after iterating through a few frames
446 # we save the animation to get the iteration because we are not
447 # in an interactive framework.
448 ax = fig_test.add_subplot()
449 ax.set_xlim(0, 2 * np.pi)
450 ax.set_ylim(-1, 1)
451 x = np.linspace(0, 2 * np.pi, 100)
452 line, = ax.plot([], [])
453
454 def init():
455 line.set_data([], [])
456 return line,
457
458 def animate(i):
459 line.set_data(x, np.sin(x + i / 100))
460 return line,
461
462 anim = animation.FuncAnimation(
463 fig_test, animate, init_func=init, frames=5,
464 blit=True, repeat=False)
465 anim.save(tmp_path / "test.gif")
466
467 # Reference figure without animation
468 ax = fig_ref.add_subplot()
469 ax.set_xlim(0, 2 * np.pi)
470 ax.set_ylim(-1, 1)
471
472 # 5th frame's data
473 ax.plot(x, np.sin(x + 4 / 100))
474
475
476@pytest.mark.parametrize('anim', [dict(klass=dict)], indirect=['anim'])

Callers

nothing calls this directly

Calls 5

add_subplotMethod · 0.80
saveMethod · 0.80
set_xlimMethod · 0.45
set_ylimMethod · 0.45
plotMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…