You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
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.
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).
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.
Activity
dstansby commentedon Nov 21, 2016
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 commentedon Nov 21, 2016
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 commentedon Nov 21, 2016
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 commentedon 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 forndim == 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.