-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
shims for categorical support for numpy < 1.8 #8591
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
We already require at least numpy 1.7. It may be better to just jump the minimum version to 1.8. For example, the oldest Ubuntu still not EOL'd is trusty LTS, which has 1.8.1 (https://wiki.ubuntu.com/Releases and http://packages.ubuntu.com/trusty/python/python-numpy). |
I'm fine with whichever. This supports down to 1.6 only because I couldn't reproduce the bug on 1.7. (And so don't know if the unicode issues appear with 1.7...) Also dunno what codecov is mad about |
my guess is that by removing the decorator definition + applications you reduced the number of lines (and covered lines) in the tests files (which out changing the number of not-covered lines) so the fraction of covered lines went down slightly. |
lib/matplotlib/category.py
Outdated
import collections | ||
|
||
|
||
def shim_array(data): |
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.
might be better to do this as
if LooseVersion(np.__version__) < LooseVersion('1.8.0'):
def shim_array(data):
...
else:
def shim_array(data):
return np.array(data, dtype=np.unicode)
so we only do the version check at import time.
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.
Left one comment (to avoid frequently checking the numpy version, but do not think it is worth holding the PR)
Updated based @tacaswell's comments. Can this be closed out? |
Matplotlib doesn't render unicode strings with numpy below 1.7 and numpy below 1.8 is buggy with mixed type arrays, truncating strings to the size of the smallest string in the mixed type array. This PR introduces a shim that converts mixed type elements to strings before converting the input into an array, and it has a shim that decodes and encodes unicode, essentially forcing it into utf endpoint ASCII gibberish.
This PR closes #7988
PR Checklist