Rectangle patch angle attribute and patch __str__ improvements#7536
Rectangle patch angle attribute and patch __str__ improvements#7536dopplershift merged 2 commits intomatplotlib:masterfrom
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. |
dopplershift
left a comment
There was a problem hiding this comment.
Looks good overall to me. Just the minor pep8 nit that the tests picked up.
lib/matplotlib/patches.py
Outdated
| 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.
Can you wrap this line so it's less than 80 columns?
There was a problem hiding this comment.
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
dopplershift
left a comment
There was a problem hiding this comment.
Thanks for the other additions!
Unfortunately, you added a new > length 80 line.
lib/matplotlib/tests/test_patches.py
Outdated
| 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.
Unfortunately, now this line is too long.
There was a problem hiding this comment.
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_patchmethod to convert regions to matplotlib patch objects for plotting.While writing a test for the rectangle region / patch, I noticed that
matplotlib.patches.Rectangle._anglethat 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
angleattribute 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.anglespecifically?