Skip to content

Commit

Permalink
pinned down hacks only needed for 1.6, and improved unicode tests
Browse files Browse the repository at this point in the history
  • Loading branch information
story645 authored and tacaswell committed Jul 8, 2016
1 parent 8e68409 commit 541ee08
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/matplotlib/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# pure hack for numpy 1.6 support
from distutils.version import LooseVersion

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


def to_array(data, maxlen=100):
Expand Down
24 changes: 10 additions & 14 deletions lib/matplotlib/tests/test_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def test_map_unicode(self):
self.assertListEqual(act, exp)

def test_map_data(self):
act = cat.map_categories("a")
exp = [('a', 0)]
act = cat.map_categories("hello world")
exp = [("hello world", 0)]
self.assertListEqual(act, exp)

def test_map_data_basic(self):
Expand Down Expand Up @@ -86,20 +86,16 @@ def setUp(self):
self.cc = cat.StrCategoryConverter()
self.axis = FakeAxis()

def test_convert_accepts_unicode(self):
self.axis.unit_data = [('a', 0), ('b', 1)]
c1 = self.cc.convert("a", None, self.axis)
c2 = self.cc.convert(u"a", None, self.axis)
self.assertEqual(c1, c2)

c1 = self.cc.convert(["a", "b"], None, self.axis)
c2 = self.cc.convert([u"a", u"b"], None, self.axis)
np.testing.assert_array_equal(c1, c2)
def test_convert_unicode(self):
self.axis.unit_data = [("Здравствуйте мир", 42)]
act = self.cc.convert("Здравствуйте мир", None, self.axis)
exp = 42
self.assertEqual(act, exp)

def test_convert_single(self):
self.axis.unit_data = [('a', 0)]
act = self.cc.convert("a", None, self.axis)
exp = 0.0
self.axis.unit_data = [("hello world", 42)]
act = self.cc.convert("hello world", None, self.axis)
exp = 42
self.assertEqual(act, exp)

def test_convert_basic(self):
Expand Down

0 comments on commit 541ee08

Please sign in to comment.