Skip to content

Remove numpy 1.6 specific work-arounds #7484

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

Closed
tacaswell opened this issue Nov 18, 2016 · 4 comments · Fixed by #7494
Closed

Remove numpy 1.6 specific work-arounds #7484

tacaswell opened this issue Nov 18, 2016 · 4 comments · Fixed by #7494
Labels
Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues
Milestone

Comments

@tacaswell
Copy link
Member

In #7396 / #7483 we bumped the minimum numpy version to 1.7.1. We have a number of workarounds in the code base which should be removed

From master:

09:41 $ ack -i 'numpy.*1\.6' --python
lib/matplotlib/cbook.py
2585:# Numpy > 1.6.x deprecates putmask in favor of the new copyto.

lib/matplotlib/tri/triinterpolate.py
1270:        # - it is new in numpy 1.6

lib/matplotlib/category.py
17:#  pure hack for numpy 1.6 support
83:    """Helper function for numpy 1.6, can be replaced with

lib/matplotlib/tests/test_category.py
160:        # Image test would fail on numpy 1.6

lib/matplotlib/colors.py
179:    # Python 2.7 / numpy 1.6 apparently require this to return builtin floats,

I would prefer is we not backport these for 2.0 (just being excessively conservative).

attn @story645

@tacaswell tacaswell added the Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues label Nov 18, 2016
@tacaswell tacaswell added this to the 2.1 (next point release) milestone Nov 18, 2016
@dstansby
Copy link
Member

The first 4 of those should be fixed in my pull request. The last two I'm not entirely sure what the comments mean/what needs changing...

@story645
Copy link
Member

lib/matplotlib/tests/test_category.py
160:        # Image test would fail on numpy 1.6

is just that numpy1.6 doesn't support unicode and it's a unicode test. That comment can be removed now. And while editing that file, TestConvertToString should also be removed.

@story645
Copy link
Member

lib/matplotlib/colors.py
179:    # Python 2.7 / numpy 1.6 apparently require this to return builtin floats,

colors is weird 'cause that try catch is just to test if what's passed in is a floating point. I think the idea is that the c is expected to have been a numpy float array, and that's why it's being cast to a builtin float (as in 170). You may be able to remove that statement 'cause in theory other types were already captured, (and also remove the cast in 170)... though you may possibly need to put in a c = np.asarray(c, dtype=float) before 170 (possibly in a try/catch).

@anntzer
Copy link
Contributor

anntzer commented Nov 22, 2016

Basically something breaks later (on Py2.7+numpy1.6) if a tuple of numpy floats (rather than builtin floats) is returned. See 2fe2c26.

In fact I don't think that the version that starts with try: c = np.array(c, float) is much better (in fact, it requires additionally checking for ndim == 1), so perhaps you may just as well remove that comment without doing anything.

As a side note, either implementation suffers from the fact that the cast to float doesn't error when a string is passed in (as in plt.plot([1, 2], c=(".5", ".5", .5, .5))) but I don't think it's really worth checking that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants