-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Move float() casting in Rectangle patch #8938
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
Conversation
Can you cherry-pick the commit from #5422 into this PR? |
@@ -116,7 +116,7 @@ def __nonzero__( self ): | |||
= RETURN VALUE | |||
- Returns true if the value is non-zero. | |||
""" | |||
return self._value.__nonzero__() | |||
return self._value.__bool__() |
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.
This used to fail in python 3 becasue __nonzero__
isn't defined in python 3; __bool__
works for both 2 and 3.
Wasn't sure how to do the cherry-picking, so I've just merged the branch; is that okay? |
Make sure rotation x/y are cast to floats
With a bit of crafty rebasing that should be a lot better. Lets see if the tests pass... |
lib/matplotlib/tests/test_axes.py
Outdated
@@ -4946,6 +4946,11 @@ def test_ls_ds_conflict(): | |||
plt.plot(range(32), linestyle='steps-pre:', drawstyle='steps-post') | |||
|
|||
|
|||
@image_comparison(baseline_images=['bar_uint8'], extensions=['png']) |
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.
Any chance this and the test below could be written in a way that allows reusing other test images in order to avoid further bloating the repo?
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 replaced the uint8 test with a numerical check that the patches end up in the right place. Can't think of an easy way to merge the rectangle with units, but could maybe just drop the image test and just check that a rectangle with units doesn't throw any errors?
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.
Sounds fine too.
Fix non-zero for py2
Update test_units_patches.py Update test_units_patches.py
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.
👍 One less problem with units! 😈
🎉 Thanks for fixing this thorn @dstansby ! |
PR Summary
This moves the
float()
call in Rectangle right down to the method in which uint8's are a problem. This means that (with a slight fix to the jpl_units code) the test in #5422 will work.Fixes #5421 by making Rectangles work with units.