8000 pytest!=3.3,>=3.2 + addressing reviews · matplotlib/matplotlib@efec2de · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit efec2de

Browse files
committed
pytest!=3.3,>=3.2 + addressing reviews
1 parent 543d235 commit efec2de

File tree

6 files changed

+25
-27
lines changed

6 files changed

+25
-27
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: 2 additions & 5 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
@@ -780,12 +777,12 @@ def limit_range_for_scale(self, vmin, vmax):
780777
return self._scale.limit_range_for_scale(vmin, vmax, self.get_minpos())
781778

782779
@property
783-
@cbook.deprecated("2.1.1")
780+
@cbook.deprecated("2.2.0")
784781
def unit_data(self):
785782
return self._units
786783

787784
@unit_data.setter
788-
@cbook.deprecated("2.1.1")
785+
@cbook.deprecated("2.2.0")
789786
def unit_data(self, unit_data):
790787
self.set_units = unit_data
791788

lib/matplotlib/category.py

Lines changed: 13 additions & 15 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
@@ -43,10 +44,12 @@ def convert(value, unit, axis):
4344
4445
Parameters
4546
----------
46-
value: string, iterable
47-
value or list of values to plot
48-
unit:
49-
axis:
47+
value: string or iterable
48+
value or list of values to be converted
49+
unit: None
50+
units to use for an axis with string data
51+
axis: :class:`~matplotlib.axes.Axes`
52+
axis on which the converted value is plotted
5053
"""
5154
# dtype = object preserves numerical pass throughs
5255
values = np.atleast_1d(np.array(value, dtype=object))
@@ -76,7 +79,7 @@ def axisinfo(unit, axis):
7679
return units.AxisInfo(majloc=majloc, majfmt=majfmt)
7780

7881
@staticmethod
79-
def default_units(data=None, axis=None):
82+
def default_units(data, axis):
8083
# the conversion call stack is supposed to be
8184
# default_units->axis_info->convert
8285
if axis.units is None:
@@ -130,11 +133,10 @@ def __init__(self, data=None):
130133
data: iterable
131134
sequence of string values
132135
"""
133-
if data is None:
134-
data = ()
135136
self._mapping = OrderedDict()
136137
self._counter = itertools.count(start=0)
137-
self.update(data)
138+
if data is not None:
139+
self.update(data)
138140

139141
def update(self, data):
140142
"""Maps new values to integer identifiers.
@@ -149,13 +151,9 @@ def update(self, data):
149151
TypeError
150152
If the value in data is not a string, unicode, bytes type
151153
"""
154+
data = np.atleast_1d(np.array(data, dtype=object))
152155

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:
156+
for val in OrderedDict.fromkeys(data):
159157
if not isinstance(val, VALID_TYPES):
160158
raise TypeError("{val!r} is not a string".format(val=val))
161159
if val not in self._mapping:

lib/matplotlib/tests/test_category.py

Lines changed: 7 additions & 4 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,17 +256,18 @@ 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)
260263
@pytest.mark.parametrize("xdata", fvalues, ids=fids)
261-
def test_plot_failures(self, ax, plotter, xdata):
264+
def test_mixed_type_exception(self, ax, plotter, xdata):
262265
with pytest.raises(TypeError):
263266
plotter(ax, xdata, [1, 2])
264267

265268
@pytest.mark.parametrize("plotter", PLOT_BROKEN_LIST, ids=PLOT_BROKEN_IDS)
266269
@pytest.mark.parametrize("xdata", fvalues, ids=fids)
267-
def test_plot_failures_update(self, ax, plotter, xdata):
270+
def test_mixed_type_update_exception(self, ax, plotter, xdata):
268271
with pytest.raises(TypeError):
269272
plotter(ax, [0, 3], [1, 3])
270273
plotter(ax, xdata, [1, 2])

0 commit comments

Comments
 (0)
0