Skip to content

Commit 541ee08

Browse files
story645tacaswell
authored andcommitted
pinned down hacks only needed for 1.6, and improved unicode tests
1 parent 8e68409 commit 541ee08

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

lib/matplotlib/category.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# pure hack for numpy 1.6 support
1717
from distutils.version import LooseVersion
1818

19-
NP_NEW = (LooseVersion(np.version.version) > LooseVersion('1.10'))
19+
NP_NEW = (LooseVersion(np.version.version) >= LooseVersion('1.7'))
2020

2121

2222
def to_array(data, maxlen=100):

lib/matplotlib/tests/test_category.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def test_map_unicode(self):
4242
self.assertListEqual(act, exp)
4343

4444
def test_map_data(self):
45-
act = cat.map_categories("a")
46-
exp = [('a', 0)]
45+
act = cat.map_categories("hello world")
46+
exp = [("hello world", 0)]
4747
self.assertListEqual(act, exp)
4848

4949
def test_map_data_basic(self):
@@ -86,20 +86,16 @@ def setUp(self):
8686
self.cc = cat.StrCategoryConverter()
8787
self.axis = FakeAxis()
8888

89-
def test_convert_accepts_unicode(self):
90-
self.axis.unit_data = [('a', 0), ('b', 1)]
91-
c1 = self.cc.convert("a", None, self.axis)
92-
c2 = self.cc.convert(u"a", None, self.axis)
93-
self.assertEqual(c1, c2)
94-
95-
c1 = self.cc.convert(["a", "b"], None, self.axis)
96-
c2 = self.cc.convert([u"a", u"b"], None, self.axis)
97-
np.testing.assert_array_equal(c1, c2)
89+
def test_convert_unicode(self):
90+
self.axis.unit_data = [("Здравствуйте мир", 42)]
91+
act = self.cc.convert("Здравствуйте мир", None, self.axis)
92+
exp = 42
93+
self.assertEqual(act, exp)
9894

9995
def test_convert_single(self):
100-
self.axis.unit_data = [('a', 0)]
101-
act = self.cc.convert("a", None, self.axis)
102-
exp = 0.0
96+
self.axis.unit_data = [("hello world", 42)]
97+
act = self.cc.convert("hello world", None, self.axis)
98+
exp = 42
10399
self.assertEqual(act, exp)
104100

105101
def test_convert_basic(self):

0 commit comments

Comments
 (0)