Skip to content

Remove some numpy 1.6 workarounds #7494

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 11 commits into from
Nov 24, 2016
Prev Previous commit
Next Next commit
Simplifiy to_array for numpy >= 1.7
  • Loading branch information
dstansby committed Nov 21, 2016
commit 79b9ee07924592cd9bc7854937b5be02bcdb4fe6
17 changes: 1 addition & 16 deletions lib/matplotlib/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,8 @@
import matplotlib.ticker as ticker


# pure hack for numpy 1.6 support
from distutils.version import LooseVersion

NP_NEW = (LooseVersion(np.version.version) >= LooseVersion('1.7'))


def to_array(data, maxlen=100):
if NP_NEW:
return np.array(data, dtype=np.unicode)
if cbook.is_scalar_or_string(data):
data = [data]
try:
vals = np.array(data, dtype=('|S', maxlen))
except UnicodeEncodeError:
# this yields gibberish
vals = np.array([convert_to_string(d) for d in data])
return vals
return np.array(data, dtype=np.unicode)


class StrCategoryConverter(units.ConversionInterface):
Expand Down