Merged
Conversation
tacaswell
approved these changes
Jun 2, 2022
tacaswell
approved these changes
Jun 2, 2022
ianhi
approved these changes
Jun 2, 2022
|
|
||
| if self._force_full or np.any(pixels[:, :, 3] != 255): | ||
| if (self._force_full | ||
| or buff.shape != self._last_buff.shape |
Contributor
There was a problem hiding this comment.
may be nice to add a comment as well about this line. It took me a while to hunt down why it was ok to compare the initial np.empty((0,0)) with the buffer and this line is the escape
tacaswell
reviewed
Jun 2, 2022
|
|
||
| if self._force_full or np.any(pixels[:, :, 3] != 255): | ||
| if (self._force_full | ||
| or buff.shape != self._last_buff.shape |
Member
There was a problem hiding this comment.
Suggested change
| or buff.shape != self._last_buff.shape | |
| # If the buffer has changed size we need to do a full draw | |
| or buff.shape != self._last_buff.shape |
- Directly reuse FigureCanvasAgg.get_renderer. We don't need to init _last_buff there as we can just use buff.copy() in get_diff_image() (If we really care about reusing the same array whenever possible, we could add a shape check before the removed copyto() and reuse the old array if the shapes match, but I doubt it matters.) Instead, init it once to a non-valid shape in the constructor. Note that the comments in the function were outdated since 78c182d. - First creating `pixels` and then viewing it as `buff` is slighly simpler than doing it the other way round.
Contributor
Author
|
Added comment as requested. |
oscargus
approved these changes
Jun 3, 2022
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Directly reuse FigureCanvasAgg.get_renderer. We don't need to init
_last_buff there as we can just use buff.copy() in get_diff_image()
(If we really care about reusing the same array whenever possible, we
could add a shape check before the removed copyto() and reuse the old
array if the shapes match, but I doubt it matters.) Instead, init it
once to a non-valid shape in the constructor.
Note that the comments in the function were outdated since 78c182d.
First creating
pixelsand then viewing it asbuffis slighlysimpler than doing it the other way round.
The animation example in #19059 works for me.
PR Summary
PR Checklist
Tests and Styling
pytestpasses).flake8-docstringsand runflake8 --docstring-convention=all).Documentation
doc/users/next_whats_new/(follow instructions in README.rst there).doc/api/next_api_changes/(follow instructions in README.rst there).