Skip to content

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

Merged
merged 6 commits into from
Jul 26, 2017
Merged

Conversation

dstansby
Copy link
Member

@dstansby dstansby commented Jul 25, 2017

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.

@tacaswell
Copy link
Member

Can you cherry-pick the commit from #5422 into this PR?

@tacaswell tacaswell added this to the 2.1 (next point release) milestone Jul 25, 2017
@tacaswell tacaswell added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Jul 25, 2017
@@ -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__()
Copy link
Member Author

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.

@dstansby
Copy link
Member Author

Wasn't sure how to do the cherry-picking, so I've just merged the branch; is that okay?

dstansby added 2 commits July 25, 2017 22:32
Make sure rotation x/y are cast to floats
@dstansby
Copy link
Member Author

With a bit of crafty rebasing that should be a lot better. Lets see if the tests pass...

@@ -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'])
Copy link
Contributor

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?

Copy link
Member Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds fine too.

Copy link
Contributor

@dopplershift dopplershift left a 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! 😈

@QuLogic QuLogic merged commit c38205a into matplotlib:master Jul 26, 2017
@tacaswell
Copy link
Member

🎉 Thanks for fixing this thorn @dstansby !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. topic: units and array ducktypes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rectangle patch constructor fails with units
6 participants