Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8d77466

Browse files
committed
py2.7 unicode bug, pytest 3.4 on travis and appveyor
1 parent 543d235 commit 8d77466

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ install:
6666
- activate test-environment
6767
- echo %PYTHON_VERSION% %TARGET_ARCH%
6868
# pytest-cov>=2.3.1 due to https://github.com/pytest-dev/pytest-cov/issues/124
69-
- pip install -q "pytest!=3.3.0" "pytest-cov>=2.3.1" pytest-rerunfailures pytest-timeout pytest-xdist
69+
- pip install -q "pytest>=3.4.0" "pytest-cov>=2.3.1" pytest-rerunfailures pytest-timeout pytest-xdist
7070

7171
# Apply patch to `subprocess` on Python versions > 2 and < 3.6.3
7272
# https://github.com/matplotlib/matplotlib/issues/9176

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ env:
5252
- NUMPY=numpy
5353
- PANDAS=
5454
- PYPARSING=pyparsing
55-
- PYTEST=pytest!=3.3.0
55+
- PYTEST="pytest>=3.4.0"
5656
- PYTEST_COV=pytest-cov
5757
- PYTEST_PEP8=
5858
- SPHINX=sphinx

lib/matplotlib/category.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from __future__ import (absolute_import, division, print_function,
66
unicode_literals)
77

8-
from collections import Iterable, OrderedDict
8+
from collections import OrderedDict
99
import itertools
1010

1111
import six
@@ -46,7 +46,7 @@ def convert(value, unit, axis):
4646
value: string, iterable
4747
value or list of values to plot
4848
unit:
49-
axis:
49+
axis: matplotlib axis object on which the value is plotted
5050
"""
5151
# dtype = object preserves numerical pass throughs
5252
values = np.atleast_1d(np.array(value, dtype=object))
@@ -149,13 +149,9 @@ def update(self, data):
149149
TypeError
150150
If the value in data is not a string, unicode, bytes type
151151
"""
152+
data = np.atleast_1d(np.array(data, dtype=object))
152153

153-
if (isinstance(data, VALID_TYPES) or
154-
not isinstance(data, Iterable)):
155-
data = [data]
156-
157-
unsorted_unique = OrderedDict.fromkeys(data)
158-
for val in unsorted_unique:
154+
for val in OrderedDict.fromkeys(data):
159155
if not isinstance(val, VALID_TYPES):
160156
raise TypeError("{val!r} is not a string".format(val=val))
161157
if val not in self._mapping:

lib/matplotlib/tests/test_category.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,15 @@ def test_axisinfo(self):
121121
def test_default_units(self):
122122
assert isinstance(self.cc.default_units(["a"], self.ax), cat.UnitData)
123123

124+
124125
@pytest.fixture
125126
def ax():
126127
return plt.figure().subplots()
127128

128129
PLOT_LIST = [Axes.scatter, Axes.plot, Axes.bar]
129130
PLOT_IDS = ["scatter", "plot", "bar"]
130131

132+
131133
class TestStrCategoryLocator(object):
132134
def test_StrCategoryLocator(self):
133135
locs = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
@@ -152,14 +154,14 @@ def test_StrCategoryFormatter(self, ax, ydata):
152154
unit = cat.UnitData(ydata)
153155
labels = cat.StrCategoryFormatter(unit)
154156
for i, d in enumerate(ydata):
155-
assert labels(i, i) == d
157+
assert labels(i, i) == cat.to_str(d)
156158

157159
@pytest.mark.parametrize("ydata", cases, ids=ids)
158160
@pytest.mark.parametrize("plotter", PLOT_LIST, ids=PLOT_IDS)
159161
def test_StrCategoryFormatterPlot(self, ax, ydata, plotter):
160162
plotter(ax, range(len(ydata)), ydata)
161163
for i, d in enumerate(ydata):
162-
assert ax.yaxis.major.formatter(i, i) == d
164+
assert ax.yaxis.major.formatter(i, i) == cat.to_str(d)
163165
assert ax.yaxis.major.formatter(i+1, i+1) == ""
164166
assert ax.yaxis.major.formatter(0, None) == ""
165167

0 commit comments

Comments
 (0)