Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
QuLogic merged 1 commit intomatplotlib:masterfromanntzer:patches
Sep 29, 2020

Conversation

anntzer
Copy link
Contributor

In Rectangle: no need to keep track and update ofself._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 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

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (runflake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • Conforms to Matplotlib style conventions (installflake8-docstrings andpydocstyle<4 and runflake8 --docstring-convention=all).
  • New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).

Copy link
Contributor

@dopplershiftdopplershift left a 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?

@anntzer
Copy link
ContributorAuthor

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...

@QuLogic
Copy link
Member

That's true forRectangle, but notRegularPolygon? Also, something thatRegularPolygon setter could have had, but appears to have been missed, is setting itsstale property.

@anntzer
Copy link
ContributorAuthor

RegularPolygon calls_update_transform before returning the patch_transform, so we're fine.
OTOH you are right about staleness...

@QuLogic
Copy link
Member

QuLogic commentedSep 28, 2020
edited
Loading

Yes, but someone could callget_patch_transform and just hang onto that even after changing things. For example,

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.
@anntzer
Copy link
ContributorAuthor

Fair point re: RegularPolygon.get_patch_transform; fixed.

@QuLogicQuLogic merged commitfc18ccc intomatplotlib:masterSep 29, 2020
@QuLogicQuLogic added this to thev3.4.0 milestoneSep 29, 2020
@anntzeranntzer deleted the patches branchSeptember 29, 2020 23:08
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@dopplershiftdopplershiftdopplershift approved these changes

@QuLogicQuLogicQuLogic approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.4.0
Development

Successfully merging this pull request may close these issues.

3 participants
@anntzer@QuLogic@dopplershift

[8]ページ先頭

©2009-2025 Movatter.jp