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
Rectangle patch angle attribute and patch __str__ improvements #7536
Conversation
The usage of |
@dopplershift - I've attached a commit with the change you suggest. While looking at the file I noticed that I see that you don't have unit tests with asserts on simple data members like |
Current coverage is 61.88% (diff: 100%)@@ master #7536 diff @@
==========================================
Files 173 173
Lines 56140 56140
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
Hits 34743 34743
Misses 21397 21397
Partials 0 0
|
Thanks! If you're willing to do the work, I'd say yes to both of your questions; I'm certainly not going to say no to more tests. |
OK, I'll do it here. Side comment: when I try to run the tests following your docs, I get this:
I presume that's because it's picking up the |
@dopplershift - Please review. |
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.
Looks good overall to me. Just the minor pep8 nit that the tests picked up.
@@ -1394,8 +1395,9 @@ class Ellipse(Patch): | |||
A scale-free ellipse. | |||
""" | |||
def __str__(self): | |||
return "Ellipse(%s,%s;%sx%s)" % (self.center[0], self.center[1], | |||
self.width, self.height) | |||
pars = self.center[0], self.center[1], self.width, self.height, self.angle |
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.
Can you wrap this line so it's less than 80 columns?
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.
I've amended the last commit to wrap to 80 char here.
And I've thrown in a wedge, arc and test docstring.
Hope you like it.
067734c
to
d818e49
Compare
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.
Thanks for the other additions!
Unfortunately, you added a new > length 80 line.
assert str(p) == 'Wedge(center=(1, 2), r=3, theta1=4, theta2=5, width=6)' | ||
|
||
p = mpatches.Arc(xy=(1, 2), width=3, height=4, angle=5, theta1=6, theta2=7) | ||
assert str(p) == 'Arc(xy=(1, 2), width=3, height=4, angle=5, theta1=6, theta2=7)' |
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.
Unfortunately, now this line is too long.
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.
I've amended my commit to fix this PEP8 and checked PEP8 locally. Should be OK now.
Looks like just a freak windows failure (one job, unrelated). Merging... Thanks! |
We're in the process of writing an astropy.regions package for astronomers, and we're adding an
as_patch
method to convert regions to matplotlib patch objects for plotting.While writing a test for the rectangle region / patch, I noticed that
matplotlib.patches.Rectangle._angle
that was added in #1405 isn't exposed as a public attribute?If that's the case, would it be possible to expose it via an
angle
attribute orget_angle()
method?I noticed that other parameters are exposed as a wild mix of attributes and
get_
methods:Presumably there are backward-compat constraints or name collisions, that make exposing patch data members in a uniform way difficult. Is there something that can be improved in general, or for
Rectangle.angle
specifically?