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

Skip to content

Commit b0a1184

Browse files
committed
pytest!=3.3,>=3.2 + more refactoring
1 parent 543d235 commit b0a1184

File tree

6 files changed

+15
-19
lines changed

6 files changed

+15
-19
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.3.0,>=3.2.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.3.0,>=3.2.0'
5656
- PYTEST_COV=pytest-cov
5757
- PYTEST_PEP8=
5858
- SPHINX=sphinx

lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6442,7 +6442,7 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
64426442
if normed is not None:
64436443
warnings.warn("The 'normed' kwarg is deprecated, and has been "
64446444
"replaced by the 'density' kwarg.")
6445-
6445+
64466446
# basic input validation
64476447
input_empty = np.size(x) == 0
64486448
# Massage 'x' for processing.

lib/matplotlib/axis.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,9 +720,6 @@ def __init__(self, axes, pickradius=15):
720720
self.labelpad = rcParams['axes.labelpad']
721721
self.offsetText = self._get_offset_text()
722722

723-
self.majorTicks = []
724-
self.minorTicks = []
725-
726723
self.pickradius = pickradius
727724

728725
# Initialize here for testing; later add API

lib/matplotlib/category.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
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
1212

13+
1314
import numpy as np
1415

1516
import matplotlib.units as units
@@ -46,7 +47,7 @@ def convert(value, unit, axis):
4647
value: string, iterable
4748
value or list of values to plot
4849
unit:
49-
axis:
50+
axis: matplotlib axis object on which the value is plotted
5051
"""
5152
# dtype = object preserves numerical pass throughs
5253
values = np.atleast_1d(np.array(value, dtype=object))
@@ -130,11 +131,10 @@ def __init__(self, data=None):
130131
data: iterable
131132
sequence of string values
132133
"""
133-
if data is None:
134-
data = ()
135134
self._mapping = OrderedDict()
136135
self._counter = itertools.count(start=0)
137-
self.update(data)
136+
if data is not None:
137+
self.update(data)
138138

139139
def update(self, data):
140140
"""Maps new values to integer identifiers.
@@ -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: 5 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

@@ -254,6 +256,7 @@ def test_update_plot(self, ax, plotter):
254256
PLOT_BROKEN_LIST = [Axes.scatter,
255257
pytest.param(Axes.plot, marks=pytest.mark.xfail),
256258
pytest.param(Axes.bar, marks=pytest.mark.xfail)]
259+
257260
PLOT_BROKEN_IDS = ["scatter", "plot", "bar"]
258261

259262
@pytest.mark.parametrize("plotter", PLOT_BROKEN_LIST, ids=PLOT_BROKEN_IDS)

0 commit comments

Comments
 (0)