8000 Simplifiy to_array for numpy >= 1.7 · matplotlib/matplotlib@79b9ee0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 79b9ee0

Browse files
committed
Simplifiy to_array for numpy >= 1.7
1 parent 8ce11f2 commit 79b9ee0

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

lib/matplotlib/category.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,8 @@
1414
import matplotlib.ticker as ticker
1515

1616

17-
# pure hack for numpy 1.6 support
18-
from distutils.version import LooseVersion
19-
20-
NP_NEW = (LooseVersion(np.version.version) >= LooseVersion('1.7'))
21-
22-
2317
def to_array(data, maxlen=100):
24-
if NP_NEW:
25-
return np.array(data, dtype=np.unicode)
26-
if cbook.is_scalar_or_string(data):
27-
data = [data]
28-
try:
29-
vals = np.array(data, dtype=('|S', maxlen))
30-
except UnicodeEncodeError:
31-
# this yields gibberish
32-
vals = np.array([convert_to_string(d) for d in data])
33-
return vals
18+
return np.array(data, dtype=np.unicode)
3419

3520

3621
class StrCategoryConverter(units.ConversionInterface):

0 commit comments

Comments
 (0)
0