Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Simplify Rectangle and RegularPolygon.#18601
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
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.
Is there any normal circumstance where creating these transforms is slow and actually worth caching?
Uh oh!
There was an error while loading.Please reload this page.
I guess caching may be nice but wouldn't worry about it unless someone shows that this is an actual bottleneck; also in any case this PR doesn't regress on that... |
That's true for |
RegularPolygon calls |
QuLogic commentedSep 28, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Yes, but someone could call fig,ax=plt.subplots()rp=mpatches.RegularPolygon((0,2),3)ax.add_patch(rp)ax.text(0,0,'Center',ha='center',va='center',transform=rp.get_transform())rp.xy= (3,5)ax.set_xlim(-10,10)ax.set_ylim(-10,10) |
In Rectangle: no need to keep track and update of `self._x1` and`self._x2` all the time, just when we compute the patch_transform(which doesn't need to be split out into its own function, or storedinto an instance variable, given that it's never accessed via theprivate attribute name).In RegularPolygon: likewise, we can just compute the transform inget_patch_transform(), and nowhere else, so the other attributes canjust be plain attributes instead of properties that update the transformall the time.
Fair point re: RegularPolygon.get_patch_transform; fixed. |
In Rectangle: no need to keep track and update of
self._x1
andself._x2
all the time, just when we compute the patch_transform(which doesn't need to be split out into its own function, or stored
into an instance variable, given that it's never accessed via the
private attribute name).
In RegularPolygon: likewise, we can just compute the transform in
get_patch_transform(), and nowhere else, so the other attributes can
just be plain attributes instead of properties that update the transform
all the time.
PR Summary
PR Checklist
pytest
passes).flake8
on changed files to check).flake8-docstrings
andpydocstyle<4
and runflake8 --docstring-convention=all
).doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).