(tmp_path, fig_test, fig_ref)
| 442 | |
| 443 | @check_figures_equal() |
| 444 | def 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']) |
nothing calls this directly
no test coverage detected
searching dependent graphs…