Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add angle setter/getter to Rectangle #19646

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 2 commits into from
Mar 8, 2021
Merged

Conversation

dstansby
Copy link
Member

@dstansby dstansby commented Mar 5, 2021

This adds an angle property, such that the Rectangle is labelled stale when it is updated. All the other properties use set_ and get_, but to maintain backwards compatibility I've used a property here since Rectangle.angle already existed.

@timhoffm
Copy link
Member

timhoffm commented Mar 6, 2021

I propose to add set_ and get_ instead, but leave the storage in the public Rectangle.angle.

This is a consistency issue. We don't have attributes do fancy stuff (and thus have litte public attributes anyway). Defining set_ enables the use with standard mechanisms like rect.set(width=2, angle=30).

We don't need staling on .angle assignment. This has not been working and thus we don't need that for backward compatibility.

We may additionally deprecate .angle, but I'm undecided if that's worth it.

@dstansby dstansby changed the title Add angle property to Rectangle Add angle setter/getter to Rectangle Mar 6, 2021
@dstansby dstansby requested review from timhoffm and anntzer March 7, 2021 17:14
@anntzer
Copy link
Contributor

anntzer commented Mar 7, 2021

My approval still stands, although you made flake8 unhappy :)

@jklymak
Copy link
Member

jklymak commented Mar 7, 2021

Please add tests for the new setters and getters!

@anntzer anntzer removed their request for review March 7, 2021 19:15
Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think a test is strictly necessary for this, but of course @jklymak is right. Leaving open in case you want to add a test. If not, I'd also merge without.

@dstansby
Copy link
Member Author

dstansby commented Mar 8, 2021

Test added. It's a simple figure comparison to make sure that setting the rotation after patch creation does the same thing as setting it in the constructor, with some additional tests for get_angle().

@jklymak jklymak merged commit 3df5db5 into matplotlib:master Mar 8, 2021
@dstansby dstansby deleted the rect-rotate branch March 8, 2021 16:37
@QuLogic QuLogic added this to the v3.5.0 milestone Mar 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants