-
Notifications
You must be signed in to change notification settings - Fork 19
Fix idle draw animation #504
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
Open
cvanelteren
wants to merge
32
commits into
main
Choose a base branch
from
fix-idle-draw-animation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+142
−20
Open
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
7993257
animation: skip auto_layout on draw_idle
cvanelteren 93f9672
layout: skip auto_layout unless layout is dirty
cvanelteren ecf6010
layout: avoid dirtying layout on backend size updates
cvanelteren eb70a98
ci: append coverage data with xdist
cvanelteren 0d3bf5b
ci: force pytest-cov plugin with xdist
cvanelteren ab165b5
ci: fall back to full tests when selection is empty
cvanelteren 008ddb1
ci: handle empty selected tests under bash -e
cvanelteren 4d6c0a2
ci: fall back to full baseline generation on empty selection
cvanelteren b2ea1a3
ci: treat missing nodeids as empty selection
cvanelteren a959cd6
ci: run coverage without xdist to avoid worker gaps
cvanelteren c9a0f0f
ci: quiet pytest output
cvanelteren e3ba31a
ci: suppress pytest warnings output
cvanelteren 9de5e83
ci: stabilize pytest exit handling
cvanelteren bcffb19
ci: retry pytest without xdist on nonzero exit
cvanelteren 2591a82
ci: run main test step without xdist
cvanelteren f0b0622
ci: filter missing nodeids before pytest
cvanelteren 9736984
ci: bump cache keys for test map and baselines
cvanelteren ed69c48
ci: rely on coverage step for test gating
cvanelteren e119fbb
ci: drop coverage step from build workflow
cvanelteren 0d1564f
Merge branch 'main' into fix-idle-draw-animation
cvanelteren 4942b5b
Remove workflow changes from branch
cvanelteren 9e66b83
run test single thread
cvanelteren 5f4e25e
Prevent None from interfering with tickers
cvanelteren 1492c35
Remove git install
cvanelteren 23f0466
Harden workflow
cvanelteren 71e35b4
Merge branch 'main' into fix-idle-draw-animation
cvanelteren b6c0646
Merge branch 'main' into fix-idle-draw-animation
cvanelteren 7259915
update workflow
cvanelteren 0cab5f0
Restore workflow files
cvanelteren e0cb1d7
Merge branch 'main' into fix-idle-draw-animation
cvanelteren 01040ed
Merge branch 'main' into fix-idle-draw-animation
cvanelteren 215d664
Apply suggestion from @beckermr
beckermr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| from unittest.mock import MagicMock | ||
|
|
||
| import numpy as np | ||
| import pytest | ||
| from matplotlib.animation import FuncAnimation | ||
|
|
||
| import ultraplot as uplt | ||
|
|
||
|
|
||
| def test_auto_layout_not_called_on_every_frame(): | ||
| """ | ||
| Test that auto_layout is not called on every frame of a FuncAnimation. | ||
| """ | ||
| fig, ax = uplt.subplots() | ||
| fig.auto_layout = MagicMock() | ||
|
|
||
| x = np.linspace(0, 2 * np.pi, 100) | ||
| y = np.sin(x) | ||
| (line,) = ax.plot(x, y) | ||
|
|
||
| def update(frame): | ||
| line.set_ydata(np.sin(x + frame / 10.0)) | ||
| return (line,) | ||
|
|
||
| ani = FuncAnimation(fig, update, frames=10, blit=False) | ||
| # The animation is not actually run, but the initial draw will call auto_layout once | ||
| fig.canvas.draw() | ||
|
|
||
| assert fig.auto_layout.call_count == 1 | ||
|
|
||
|
|
||
| def test_draw_idle_skips_auto_layout_after_first_draw(): | ||
| """ | ||
| draw_idle should not re-run auto_layout after the initial draw. | ||
| """ | ||
| fig, ax = uplt.subplots() | ||
| fig.auto_layout = MagicMock() | ||
|
|
||
| fig.canvas.draw() | ||
| assert fig.auto_layout.call_count == 1 | ||
|
|
||
| fig.canvas.draw_idle() | ||
| assert fig.auto_layout.call_count == 1 | ||
|
|
||
|
|
||
| def test_layout_array_no_crash(): | ||
| """ | ||
| Test that using layout_array with FuncAnimation does not crash. | ||
| """ | ||
| layout = [[1, 1], [2, 3]] | ||
| fig, axs = uplt.subplots(array=layout) | ||
|
|
||
| def update(frame): | ||
| for ax in axs: | ||
| ax.clear() | ||
| ax.plot(np.sin(np.linspace(0, 2 * np.pi) + frame / 10.0)) | ||
|
|
||
| ani = FuncAnimation(fig, update, frames=10) | ||
| # The test passes if no exception is raised | ||
| fig.canvas.draw() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.