-
-
Notifications
You must be signed in to change notification settings - Fork 8k
MNT: Remove cached renderer from figure #23202
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
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
``Axes.get_renderer_cache`` | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
The canvas now takes care of the renderer and whether to cache it | ||
or not. The alternative is to call ``axes.figure.canvas.get_renderer()``. |
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On one hand, this call making a new renderer would be odd, my understanding of why this exists is a helper specifcally for managing blitting where you can rely on the render not only existing, but also having already had everything else of interest rasterized. By caching the renderer on the figure we are saying "yes, this figure was rendered with this renderer so we are sure that it is holding the state of everything else, also you can use it to draw the given artist". If we cache / create the renderer on the canvas we only get "this renderer will work".
However, that is a narrow case and while I can think of stories of how this would break someone ("catch the
AttirbuteError
to know we need to re-render the whole figure"....but for that to make sense we would also have to be sure that we were properly invalidating the cache (by setting it to None) when we resize the Figure).Which is a very long way of saying that I am 👍🏻 on this change (despite some risk), will need an API change note.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree with all of that. I was a bit surprised that there wasn't more code churn in this PR which does make me a bit hesitant about what the edge-cases I'm missing are...
One thing I thought about is that we have a
get_renderer()
method on Agg/Cairo Canvas' now, but not on PDF, but the PDF requires a file handle so it isn't as straightforward to just point to a renderer. I was curious if that was perhaps the idea behind the figure caching in the first place... But, surprisingly it didn't affect any of the PDF tests.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pdf and svg renderer's work in a streaming mode so going back to one only makes limited sense in general and makes no sense in this case.