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

Skip to content

Commit e08a9f8

Browse files
Merge branch 'master' into Bugfix-16583
2 parents 98081a8 + 50242cf commit e08a9f8

27 files changed

+114
-99
lines changed

doc/api/next_api_changes/deprecations.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,22 @@ The following validators, defined in `.rcsetup`, are deprecated:
225225
``validate_movie_frame_fmt``, ``validate_axis_locator``,
226226
``validate_movie_html_fmt``, ``validate_grid_axis``,
227227
``validate_axes_titlelocation``, ``validate_toolbar``,
228+
<<<<<<< HEAD
228229
``validate_ps_papersize``, ``validate_legend_loc``,
229230
``validate_bool_maybe_none``, ``validate_hinting``,
230231
``validate_movie_writers``.
231232
To test whether an rcParam value would be acceptable, one can test e.g. ``rc =
232233
RcParams(); rc[k] = v`` raises an exception.
234+
||||||| constructed merge base
235+
``validate_ps_papersize``, ``validate_legend_log``. To test whether an rcParam
236+
value would be acceptable, one can test e.g. ``rc = RcParams(); rc[k] = v``
237+
raises an exception.
238+
=======
239+
``validate_ps_papersize``, ``validate_legend_loc``,
240+
``validate_webagg_address``.
241+
To test whether an rcParam value would be acceptable, one can test e.g. ``rc =
242+
RcParams(); rc[k] = v`` raises an exception.
243+
>>>>>>> Deprecate validate_webagg_address.
233244

234245
Stricter rcParam validation
235246
~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -284,3 +295,7 @@ is deprecated, set the offset to 0 instead.
284295
``RendererCairo.fontweights``, ``RendererCairo.fontangles``
285296
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
286297
... are deprecated.
298+
299+
``autofmt_xdate(which=None)``
300+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
301+
This is deprecated, use its more explicit synonym, ``which="major"``, instead.

examples/images_contours_and_fields/tricontour_smooth_delaunay.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ def experiment_res(x, y):
124124

125125
# 1) plot of the refined (computed) data contours:
126126
ax.tricontour(tri_refi, z_test_refi, levels=levels, cmap=cmap,
127-
linewidths=[2.0, 0.5, 1.0, 0.5])
127+
linewidths=[2.0, 0.5, 1.0, 0.5])
128128
# 2) plot of the expected (analytical) data contours (dashed):
129129
if plot_expected:
130130
ax.tricontour(tri_refi, z_expected, levels=levels, cmap=cmap,
131-
linestyles='--')
131+
linestyles='--')
132132
# 3) plot of the fine mesh on which interpolation was done:
133133
if plot_refi_tri:
134134
ax.triplot(tri_refi, color='0.97')

examples/images_contours_and_fields/tricontour_smooth_user.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ def function_z(x, y):
6969
cmap = cm.get_cmap(name='terrain', lut=None)
7070
ax.tricontourf(tri_refi, z_test_refi, levels=levels, cmap=cmap)
7171
ax.tricontour(tri_refi, z_test_refi, levels=levels,
72-
colors=['0.25', '0.5', '0.5', '0.5', '0.5'],
73-
linewidths=[1.0, 0.5, 0.5, 0.5, 0.5])
72+
colors=['0.25', '0.5', '0.5', '0.5', '0.5'],
73+
linewidths=[1.0, 0.5, 0.5, 0.5, 0.5])
7474

7575
ax.set_title("High-resolution tricontouring")
7676

lib/matplotlib/_cm.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,22 @@ def _g36(x): return 2 * x - 1
240240
(0.857143, 0.937500, 0.937500),
241241
(1.0, 0.09375, 0.09375))}
242242

243-
_jet_data = {'red': ((0., 0, 0), (0.35, 0, 0), (0.66, 1, 1), (0.89, 1, 1),
244-
(1, 0.5, 0.5)),
245-
'green': ((0., 0, 0), (0.125, 0, 0), (0.375, 1, 1), (0.64, 1, 1),
246-
(0.91, 0, 0), (1, 0, 0)),
247-
'blue': ((0., 0.5, 0.5), (0.11, 1, 1), (0.34, 1, 1),
248-
(0.65, 0, 0), (1, 0, 0))}
243+
_jet_data = {'red': ((0.00, 0, 0),
244+
(0.35, 0, 0),
245+
(0.66, 1, 1),
246+
(0.89, 1, 1),
247+
(1.00, 0.5, 0.5)),
248+
'green': ((0.000, 0, 0),
249+
(0.125, 0, 0),
250+
(0.375, 1, 1),
251+
(0.640, 1, 1),
252+
(0.910, 0, 0),
253+
(1.000, 0, 0)),
254+
'blue': ((0.00, 0.5, 0.5),
255+
(0.11, 1, 1),
256+
(0.34, 1, 1),
257+
(0.65, 0, 0),
258+
(1.00, 0, 0))}
249259

250260
_pink_data = {'red': ((0., 0.1178, 0.1178), (0.015873, 0.195857, 0.195857),
251261
(0.031746, 0.250661, 0.250661),

lib/matplotlib/axes/_axes.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ def get_title(self, loc="center"):
114114
title = cbook._check_getitem(titles, loc=loc.lower())
115115
return title.get_text()
116116

117-
def set_title(self, label, fontdict=None, loc=None, pad=None,
118-
**kwargs):
117+
def set_title(self, label, fontdict=None, loc=None, pad=None, **kwargs):
119118
"""
120119
Set a title for the axes.
121120
@@ -1417,8 +1416,8 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
14171416

14181417
colls = []
14191418
for position, lineoffset, linelength, linewidth, color, linestyle in \
1420-
zip(positions, lineoffsets, linelengths, linewidths,
1421-
colors, linestyles):
1419+
zip(positions, lineoffsets, linelengths, linewidths,
1420+
colors, linestyles):
14221421
coll = mcoll.EventCollection(position,
14231422
orientation=orientation,
14241423
lineoffset=lineoffset,
@@ -7992,7 +7991,7 @@ def violin(self, vpstats, positions=None, vert=True, widths=0.5,
79927991
ppmaxs = np.concatenate((ppmaxs, [cmax] * np.size(q)))
79937992
# Start rendering
79947993
artists['cquantiles'] = perp_lines(quantiles, ppmins, ppmaxs,
7995-
colors=edgecolor)
7994+
colors=edgecolor)
79967995

79977996
return artists
79987997

lib/matplotlib/axes/_secondary_axes.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ class SecondaryAxis(_AxesBase):
3939
General class to hold a Secondary_X/Yaxis.
4040
"""
4141

42-
def __init__(self, parent, orientation,
43-
location, functions, **kwargs):
42+
def __init__(self, parent, orientation, location, functions, **kwargs):
4443
"""
4544
See `.secondary_xaxis` and `.secondary_yaxis` for the doc string.
4645
While there is no need for this to be private, it should really be

lib/matplotlib/axis.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,10 @@ def get_view_interval(self):
346346

347347
def _apply_params(self, **kw):
348348
for name, target in [("gridOn", self.gridline),
349-
("tick1On", self.tick1line),
350-
("tick2On", self.tick2line),
351-
("label1On", self.label1),
352-
("label2On", self.label2)]:
349+
("tick1On", self.tick1line),
350+
("tick2On", self.tick2line),
351+
("label1On", self.label1),
352+
("label2On", self.label2)]:
353353
if name in kw:
354354
target.set_visible(kw.pop(name))
355355
if any(k in kw for k in ['size', 'width', 'pad', 'tickdir']):

lib/matplotlib/backends/qt_editor/_formlayout.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,4 +566,4 @@ def apply_test(data):
566566
print("result:", fedit(((datagroup, "Title 1", "Tab 1 comment"),
567567
(datalist, "Title 2", "Tab 2 comment"),
568568
(datalist, "Title 3", "Tab 3 comment")),
569-
"Global title"))
569+
"Global title"))

lib/matplotlib/figure.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,9 @@ def __init__(self,
253253
edgecolor=None,
254254
linewidth=0.0,
255255
frameon=None,
256-
subplotpars=None, # default to rc
257-
tight_layout=None, # default to rc figure.autolayout
258-
constrained_layout=None, # default to rc
259-
#figure.constrained_layout.use
256+
subplotpars=None, # rc figure.subplot.*
257+
tight_layout=None, # rc figure.autolayout
258+
constrained_layout=None, # rc figure.constrained_layout.use
260259
):
261260
"""
262261
Parameters
@@ -574,7 +573,8 @@ def get_constrained_layout_pads(self, relative=False):
574573

575574
return w_pad, h_pad, wspace, hspace
576575

577-
def autofmt_xdate(self, bottom=0.2, rotation=30, ha='right', which=None):
576+
def autofmt_xdate(
577+
self, bottom=0.2, rotation=30, ha='right', which='major'):
578578
"""
579579
Date ticklabels often overlap, so it is useful to rotate them
580580
and right align them. Also, a common use case is a number of
@@ -586,18 +586,19 @@ def autofmt_xdate(self, bottom=0.2, rotation=30, ha='right', which=None):
586586
Parameters
587587
----------
588588
bottom : scalar
589-
The bottom of the subplots for :meth:`subplots_adjust`.
590-
589+
The bottom of the subplots for `subplots_adjust`.
591590
rotation : angle in degrees
592591
The rotation of the xtick labels.
593-
594592
ha : str
595593
The horizontal alignment of the xticklabels.
596-
597-
which : {None, 'major', 'minor', 'both'}
598-
Selects which ticklabels to rotate. Default is None which works
599-
the same as major.
594+
which : {'major', 'minor', 'both'}, default: 'major'
595+
Selects which ticklabels to rotate.
600596
"""
597+
if which is None:
598+
cbook.warn_deprecated(
599+
"3.3", message="Support for passing which=None to mean "
600+
"which='major' is deprecated since %(since)s and will be "
601+
"removed %(removal)s.")
601602
allsubplots = all(hasattr(ax, 'is_last_row') for ax in self.axes)
602603
if len(self.axes) == 1:
603604
for label in self.axes[0].get_xticklabels(which=which):

lib/matplotlib/mathtext.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2748,7 +2748,7 @@ def symbol(self, s, loc, toks):
27482748
return [Hlist([self._make_space(0.2),
27492749
char,
27502750
self._make_space(0.2)],
2751-
do_kern = True)]
2751+
do_kern=True)]
27522752
elif c in self._punctuation_symbols:
27532753

27542754
# Do not space commas between brackets
@@ -2762,9 +2762,7 @@ def symbol(self, s, loc, toks):
27622762
if c == '.' and s[loc - 1].isdigit() and s[loc + 1].isdigit():
27632763
return [char]
27642764
else:
2765-
return [Hlist([char,
2766-
self._make_space(0.2)],
2767-
do_kern = True)]
2765+
return [Hlist([char, self._make_space(0.2)], do_kern=True)]
27682766
return [char]
27692767

27702768
accentprefixed = symbol

lib/matplotlib/projections/polar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ def draw(self, renderer, *args, **kwargs):
902902
if thetamin > thetamax:
903903
thetamin, thetamax = thetamax, thetamin
904904
rmin, rmax = ((self._realViewLim.intervaly - self.get_rorigin()) *
905-
self.get_rsign())
905+
self.get_rsign())
906906
if isinstance(self.patch, mpatches.Wedge):
907907
# Backwards-compatibility: Any subclassed Axes might override the
908908
# patch to not be the Wedge that PolarAxes uses.

lib/matplotlib/pyplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ def subplot(*args, **kwargs):
10141014
# Check for nrows and ncols, which are not valid subplot args:
10151015
if 'nrows' in kwargs or 'ncols' in kwargs:
10161016
raise TypeError("subplot() got an unexpected keyword argument 'ncols' "
1017-
"and/or 'nrows'. Did you intend to call subplots()?")
1017+
"and/or 'nrows'. Did you intend to call subplots()?")
10181018

10191019
fig = gcf()
10201020
ax = fig.add_subplot(*args, **kwargs)

lib/matplotlib/rcsetup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,7 @@ def validate_animation_writer_path(p):
992992
return p
993993

994994

995+
@cbook.deprecated("3.3")
995996
def validate_webagg_address(s):
996997
if s is not None:
997998
import socket
@@ -1026,7 +1027,7 @@ def _convert_validator_spec(key, conv):
10261027
'backend': [_auto_backend_sentinel, validate_backend],
10271028
'backend_fallback': [True, validate_bool],
10281029
'webagg.port': [8988, validate_int],
1029-
'webagg.address': ['127.0.0.1', validate_webagg_address],
1030+
'webagg.address': ['127.0.0.1', validate_string],
10301031
'webagg.open_in_browser': [True, validate_bool],
10311032
'webagg.port_retries': [50, validate_int],
10321033
'toolbar': ['toolbar2', _ignorecase(['none', 'toolbar2', 'toolmanager'])],

lib/matplotlib/tests/test_arrow_patches.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ def test_boxarrow():
4242

4343
for i, stylename in enumerate(sorted(styles)):
4444
fig.text(0.5, ((n - i) * spacing - 0.5)/figheight, stylename,
45-
ha="center",
46-
size=fontsize,
47-
transform=fig.transFigure,
48-
bbox=dict(boxstyle=stylename, fc="w", ec="k"))
45+
ha="center",
46+
size=fontsize,
47+
transform=fig.transFigure,
48+
bbox=dict(boxstyle=stylename, fc="w", ec="k"))
4949

5050

5151
def __prepare_fancyarrow_dpi_cor_test():

lib/matplotlib/tests/test_axes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,7 +1756,7 @@ def test_bar_pandas(pd):
17561756
def test_bar_pandas_indexed(pd):
17571757
# Smoke test for indexed pandas
17581758
df = pd.DataFrame({"x": [1., 2., 3.], "width": [.2, .4, .6]},
1759-
index=[1, 2, 3])
1759+
index=[1, 2, 3])
17601760
fig, ax = plt.subplots()
17611761
ax.bar(df.x, 1., width=df.width)
17621762

@@ -5456,8 +5456,8 @@ def test_title_xticks_top():
54565456
def test_title_xticks_top_both():
54575457
# Test that title moves if xticks on top of axes.
54585458
fig, ax = plt.subplots()
5459-
ax.tick_params(axis="x", bottom=True, top=True,
5460-
labelbottom=True, labeltop=True)
5459+
ax.tick_params(axis="x",
5460+
bottom=True, top=True, labelbottom=True, labeltop=True)
54615461
ax.set_title('xlabel top')
54625462
fig.canvas.draw()
54635463
assert ax.title.get_position()[1] > 1.04

lib/matplotlib/tests/test_backend_nbagg.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ def test_ipynb():
2323
with out_path.open() as out:
2424
nb = nbformat.read(out, nbformat.current_nbformat)
2525

26-
errors = [output for cell in nb.cells if "outputs" in cell
27-
for output in cell["outputs"]
28-
if output.output_type == "error"]
26+
errors = [output for cell in nb.cells for output in cell.get("outputs", [])
27+
if output.output_type == "error"]
2928
assert not errors

lib/matplotlib/tests/test_colorbar.py

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -282,27 +282,22 @@ def test_colorbar_minorticks_on_off():
282282
im = ax.pcolormesh(data, vmin=-2.3, vmax=3.3)
283283

284284
cbar = fig.colorbar(im, extend='both')
285-
cbar.minorticks_on()
286-
correct_minorticklocs = np.array([-2.2, -1.8, -1.6, -1.4, -1.2, -0.8,
287-
-0.6, -0.4, -0.2, 0.2, 0.4, 0.6,
288-
0.8, 1.2, 1.4, 1.6, 1.8, 2.2, 2.4,
289-
2.6, 2.8, 3.2])
290285
# testing after minorticks_on()
291-
np.testing.assert_almost_equal(cbar.ax.yaxis.get_minorticklocs(),
292-
correct_minorticklocs)
293-
cbar.minorticks_off()
286+
cbar.minorticks_on()
287+
np.testing.assert_almost_equal(
288+
cbar.ax.yaxis.get_minorticklocs(),
289+
[-2.2, -1.8, -1.6, -1.4, -1.2, -0.8, -0.6, -0.4, -0.2,
290+
0.2, 0.4, 0.6, 0.8, 1.2, 1.4, 1.6, 1.8, 2.2, 2.4, 2.6, 2.8, 3.2])
294291
# testing after minorticks_off()
295-
np.testing.assert_almost_equal(cbar.ax.yaxis.get_minorticklocs(),
296-
np.array([]))
292+
cbar.minorticks_off()
293+
np.testing.assert_almost_equal(cbar.ax.yaxis.get_minorticklocs(), [])
297294

298295
im.set_clim(vmin=-1.2, vmax=1.2)
299296
cbar.minorticks_on()
300-
correct_minorticklocs = np.array([-1.2, -1.1, -0.9, -0.8, -0.7, -0.6,
301-
-0.4, -0.3, -0.2, -0.1, 0.1, 0.2,
302-
0.3, 0.4, 0.6, 0.7, 0.8, 0.9,
303-
1.1, 1.2])
304-
np.testing.assert_almost_equal(cbar.ax.yaxis.get_minorticklocs(),
305-
correct_minorticklocs)
297+
np.testing.assert_almost_equal(
298+
cbar.ax.yaxis.get_minorticklocs(),
299+
[-1.2, -1.1, -0.9, -0.8, -0.7, -0.6, -0.4, -0.3, -0.2, -0.1,
300+
0.1, 0.2, 0.3, 0.4, 0.6, 0.7, 0.8, 0.9, 1.1, 1.2])
306301

307302
# tests for github issue #13257 and PR #13265
308303
data = np.random.uniform(low=1, high=10, size=(20, 20))

lib/matplotlib/tests/test_constrainedlayout.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ def test_constrained_layout6():
110110

111111
def test_constrained_layout7():
112112
"""Test for proper warning if fig not set in GridSpec"""
113-
with pytest.warns(UserWarning, match='Calling figure.constrained_layout, '
114-
'but figure not setup to do constrained layout'):
113+
with pytest.warns(
114+
UserWarning, match=('Calling figure.constrained_layout, but figure '
115+
'not setup to do constrained layout')):
115116
fig = plt.figure(constrained_layout=True)
116117
gs = gridspec.GridSpec(1, 2)
117118
gsl = gridspec.GridSpecFromSubplotSpec(2, 2, gs[0])

lib/matplotlib/tests/test_figure.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
from pathlib import Path
33
import platform
44
import warnings
5+
try:
6+
from contextlib import nullcontext
7+
except ImportError:
8+
from contextlib import ExitStack as nullcontext # Py3.6
59

610
import matplotlib as mpl
711
from matplotlib import rcParams
@@ -318,7 +322,9 @@ def test_autofmt_xdate(which):
318322
'FixedFormatter should only be used together with FixedLocator')
319323
ax.xaxis.set_minor_formatter(FixedFormatter(minors))
320324

321-
fig.autofmt_xdate(0.2, angle, 'right', which)
325+
with (pytest.warns(mpl.MatplotlibDeprecationWarning) if which is None else
326+
nullcontext()):
327+
fig.autofmt_xdate(0.2, angle, 'right', which)
322328

323329
if which in ('both', 'major', None):
324330
for label in fig.axes[0].get_xticklabels(False, 'major'):

lib/matplotlib/tests/test_image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ def test_bbox_image_inverted():
571571

572572
bbox_im = BboxImage(TransformedBbox(Bbox([[0.1, 0.2], [0.3, 0.25]]),
573573
ax.figure.transFigure),
574-
interpolation='nearest')
574+
interpolation='nearest')
575575
bbox_im.set_data(image)
576576
bbox_im.set_clip_on(False)
577577
ax.add_artist(bbox_im)

lib/matplotlib/tests/test_patches.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def test_connection_patch():
391391
coordsA = "axes fraction"
392392
coordsB = ax2.get_yaxis_transform()
393393
con = mpatches.ConnectionPatch(xyA=xyA, xyB=xyB, coordsA=coordsA,
394-
coordsB=coordsB, arrowstyle="-")
394+
coordsB=coordsB, arrowstyle="-")
395395
ax2.add_artist(con)
396396

397397

lib/matplotlib/ticker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1419,7 +1419,7 @@ def format_eng(self, num):
14191419
# instead of 1 k. Beware of the corner case of values that are beyond
14201420
# the range of SI prefixes (i.e. > 'Y').
14211421
if (abs(float(format(mant, fmt))) >= 1000
1422-
and pow10 < max(self.ENG_PREFIXES)):
1422+
and pow10 < max(self.ENG_PREFIXES)):
14231423
mant /= 1000
14241424
pow10 += 3
14251425

0 commit comments

Comments
 (0)