Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ca48799

Browse filesBrowse files
committed
Remove remaining deprecations from 3.5
1 parent 7a909fd commit ca48799
Copy full SHA for ca48799

File tree

Expand file treeCollapse file tree

17 files changed

+39
-361
lines changed
Filter options
Expand file treeCollapse file tree

17 files changed

+39
-361
lines changed

‎doc/api/prev_api_changes/api_changes_3.5.0/deprecations.rst

Copy file name to clipboardExpand all lines: doc/api/prev_api_changes/api_changes_3.5.0/deprecations.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ implement a ``convert`` method that not only accepted instances of the unit,
162162
but also unitless values (which are passed through as is). This is no longer
163163
the case (``convert`` is never called with a unitless value), and such support
164164
in `.StrCategoryConverter` is deprecated. Likewise, the
165-
`.ConversionInterface.is_numlike` helper is deprecated.
165+
``.ConversionInterface.is_numlike`` helper is deprecated.
166166

167167
Consider calling `.Axis.convert_units` instead, which still supports unitless
168168
values.

‎doc/api/prev_api_changes/api_changes_3.5.0/removals.rst

Copy file name to clipboardExpand all lines: doc/api/prev_api_changes/api_changes_3.5.0/removals.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ Arguments
282282
- The *dummy* parameter of `.RendererPgf` has been removed.
283283
- The *props* parameter of `.Shadow` has been removed; use keyword arguments
284284
instead.
285-
- The *recursionlimit* parameter of `matplotlib.test` has been removed.
285+
- The *recursionlimit* parameter of ``matplotlib.test`` has been removed.
286286
- The *label* parameter of `.Tick` has no effect and has been removed.
287287
- `~.ticker.MaxNLocator` no longer accepts a positional parameter and the
288288
keyword argument *nbins* simultaneously because they specify the same

‎doc/api/testing_api.rst

Copy file name to clipboardExpand all lines: doc/api/testing_api.rst
-5Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
**********************
44

55

6-
:func:`matplotlib.test`
7-
=======================
8-
9-
.. autofunction:: matplotlib.test
10-
116
:mod:`matplotlib.testing`
127
=========================
138

‎lib/matplotlib/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/__init__.py
-52Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,58 +1302,6 @@ def _init_tests():
13021302
"" if ft2font.__freetype_build_type__ == 'local' else "not "))
13031303

13041304

1305-
@_api.deprecated("3.5", alternative='pytest')
1306-
def test(verbosity=None, coverage=False, **kwargs):
1307-
"""Run the matplotlib test suite."""
1308-
1309-
try:
1310-
import pytest
1311-
except ImportError:
1312-
print("matplotlib.test requires pytest to run.")
1313-
return -1
1314-
1315-
if not os.path.isdir(os.path.join(os.path.dirname(__file__), 'tests')):
1316-
print("Matplotlib test data is not installed")
1317-
return -1
1318-
1319-
old_backend = get_backend()
1320-
try:
1321-
use('agg')
1322-
1323-
args = kwargs.pop('argv', [])
1324-
provide_default_modules = True
1325-
use_pyargs = True
1326-
for arg in args:
1327-
if any(arg.startswith(module_path)
1328-
for module_path in default_test_modules):
1329-
provide_default_modules = False
1330-
break
1331-
if os.path.exists(arg):
1332-
provide_default_modules = False
1333-
use_pyargs = False
1334-
break
1335-
if use_pyargs:
1336-
args += ['--pyargs']
1337-
if provide_default_modules:
1338-
args += default_test_modules
1339-
1340-
if coverage:
1341-
args += ['--cov']
1342-
1343-
if verbosity:
1344-
args += ['-' + 'v' * verbosity]
1345-
1346-
retcode = pytest.main(args, **kwargs)
1347-
finally:
1348-
if old_backend.lower() != 'agg':
1349-
use(old_backend)
1350-
1351-
return retcode
1352-
1353-
1354-
test.__test__ = False # pytest: this function is not a test
1355-
1356-
13571305
def _replacer(data, value):
13581306
"""
13591307
Either returns ``data[value]`` or passes ``data`` back, converts either to

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
-14Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5792,18 +5792,6 @@ def _interp_grid(X):
57925792
C = cbook.safe_masked_invalid(C)
57935793
return X, Y, C, shading
57945794

5795-
def _pcolor_grid_deprecation_helper(self):
5796-
grid_active = any(axis._major_tick_kw["gridOn"]
5797-
for axis in self._axis_map.values())
5798-
# explicit is-True check because get_axisbelow() can also be 'line'
5799-
grid_hidden_by_pcolor = self.get_axisbelow() is True
5800-
if grid_active and not grid_hidden_by_pcolor:
5801-
_api.warn_deprecated(
5802-
"3.5", message="Auto-removal of grids by pcolor() and "
5803-
"pcolormesh() is deprecated since %(since)s and will be "
5804-
"removed %(removal)s; please call grid(False) first.")
5805-
self.grid(False)
5806-
58075795
@_preprocess_data()
58085796
@_docstring.dedent_interpd
58095797
def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
@@ -6008,7 +5996,6 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
60085996
collection = mcoll.PolyCollection(
60095997
verts, array=C, cmap=cmap, norm=norm, alpha=alpha, **kwargs)
60105998
collection._scale_norm(norm, vmin, vmax)
6011-
self._pcolor_grid_deprecation_helper()
60125999

60136000
x = X.compressed()
60146001
y = Y.compressed()
@@ -6242,7 +6229,6 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
62426229
coords, antialiased=antialiased, shading=shading,
62436230
array=C, cmap=cmap, norm=norm, alpha=alpha, **kwargs)
62446231
collection._scale_norm(norm, vmin, vmax)
6245-
self._pcolor_grid_deprecation_helper()
62466232

62476233
coords = coords.reshape(-1, 2) # flatten the grid structure; keep x, y
62486234

‎lib/matplotlib/axes/_base.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_base.py
+14-74Lines changed: 14 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from collections.abc import Iterable, MutableSequence
1+
from collections.abc import Iterable, Sequence
22
from contextlib import ExitStack
33
import functools
44
import inspect
@@ -1403,7 +1403,7 @@ def cla(self):
14031403
else:
14041404
self.clear()
14051405

1406-
class ArtistList(MutableSequence):
1406+
class ArtistList(Sequence):
14071407
"""
14081408
A sublist of Axes children based on their type.
14091409
@@ -1414,7 +1414,7 @@ class ArtistList(MutableSequence):
14141414
This class exists only for the transition period to warn on the
14151415
deprecated modification of artist lists.
14161416
"""
1417-
def __init__(self, axes, prop_name, add_name,
1417+
def __init__(self, axes, prop_name,
14181418
valid_types=None, invalid_types=None):
14191419
"""
14201420
Parameters
@@ -1425,9 +1425,6 @@ def __init__(self, axes, prop_name, add_name,
14251425
prop_name : str
14261426
The property name used to access this sublist from the Axes;
14271427
used to generate deprecation warnings.
1428-
add_name : str
1429-
The method name used to add Artists of this sublist's type to
1430-
the Axes; used to generate deprecation warnings.
14311428
valid_types : list of type, optional
14321429
A list of types that determine which children will be returned
14331430
by this sublist. If specified, then the Artists in the sublist
@@ -1442,7 +1439,6 @@ def __init__(self, axes, prop_name, add_name,
14421439
"""
14431440
self._axes = axes
14441441
self._prop_name = prop_name
1445-
self._add_name = add_name
14461442
self._type_check = lambda artist: (
14471443
(not valid_types or isinstance(artist, valid_types)) and
14481444
(not invalid_types or not isinstance(artist, invalid_types))
@@ -1468,103 +1464,47 @@ def __getitem__(self, key):
14681464
def __add__(self, other):
14691465
if isinstance(other, (list, _AxesBase.ArtistList)):
14701466
return [*self, *other]
1467+
if isinstance(other, (tuple, _AxesBase.ArtistList)):
1468+
return (*self, *other)
14711469
return NotImplemented
14721470

14731471
def __radd__(self, other):
14741472
if isinstance(other, list):
14751473
return other + list(self)
1474+
if isinstance(other, tuple):
1475+
return other + tuple(self)
14761476
return NotImplemented
14771477

1478-
def insert(self, index, item):
1479-
_api.warn_deprecated(
1480-
'3.5',
1481-
name=f'modification of the Axes.{self._prop_name}',
1482-
obj_type='property',
1483-
alternative=f'Axes.{self._add_name}')
1484-
try:
1485-
index = self._axes._children.index(self[index])
1486-
except IndexError:
1487-
index = None
1488-
getattr(self._axes, self._add_name)(item)
1489-
if index is not None:
1490-
# Move new item to the specified index, if there's something to
1491-
# put it before.
1492-
self._axes._children[index:index] = self._axes._children[-1:]
1493-
del self._axes._children[-1]
1494-
1495-
def __setitem__(self, key, item):
1496-
_api.warn_deprecated(
1497-
'3.5',
1498-
name=f'modification of the Axes.{self._prop_name}',
1499-
obj_type='property',
1500-
alternative=f'Artist.remove() and Axes.f{self._add_name}')
1501-
del self[key]
1502-
if isinstance(key, slice):
1503-
key = key.start
1504-
if not np.iterable(item):
1505-
self.insert(key, item)
1506-
return
1507-
1508-
try:
1509-
index = self._axes._children.index(self[key])
1510-
except IndexError:
1511-
index = None
1512-
for i, artist in enumerate(item):
1513-
getattr(self._axes, self._add_name)(artist)
1514-
if index is not None:
1515-
# Move new items to the specified index, if there's something
1516-
# to put it before.
1517-
i = -(i + 1)
1518-
self._axes._children[index:index] = self._axes._children[i:]
1519-
del self._axes._children[i:]
1520-
1521-
def __delitem__(self, key):
1522-
_api.warn_deprecated(
1523-
'3.5',
1524-
name=f'modification of the Axes.{self._prop_name}',
1525-
obj_type='property',
1526-
alternative='Artist.remove()')
1527-
if isinstance(key, slice):
1528-
for artist in self[key]:
1529-
artist.remove()
1530-
else:
1531-
self[key].remove()
1532-
15331478
@property
15341479
def artists(self):
1535-
return self.ArtistList(self, 'artists', 'add_artist', invalid_types=(
1480+
return self.ArtistList(self, 'artists', invalid_types=(
15361481
mcoll.Collection, mimage.AxesImage, mlines.Line2D, mpatches.Patch,
15371482
mtable.Table, mtext.Text))
15381483

15391484
@property
15401485
def collections(self):
1541-
return self.ArtistList(self, 'collections', 'add_collection',
1486+
return self.ArtistList(self, 'collections',
15421487
valid_types=mcoll.Collection)
15431488

15441489
@property
15451490
def images(self):
1546-
return self.ArtistList(self, 'images', 'add_image',
1547-
valid_types=mimage.AxesImage)
1491+
return self.ArtistList(self, 'images', valid_types=mimage.AxesImage)
15481492

15491493
@property
15501494
def lines(self):
1551-
return self.ArtistList(self, 'lines', 'add_line',
1552-
valid_types=mlines.Line2D)
1495+
return self.ArtistList(self, 'lines', valid_types=mlines.Line2D)
15531496

15541497
@property
15551498
def patches(self):
1556-
return self.ArtistList(self, 'patches', 'add_patch',
1557-
valid_types=mpatches.Patch)
1499+
return self.ArtistList(self, 'patches', valid_types=mpatches.Patch)
15581500

15591501
@property
15601502
def tables(self):
1561-
return self.ArtistList(self, 'tables', 'add_table',
1562-
valid_types=mtable.Table)
1503+
return self.ArtistList(self, 'tables', valid_types=mtable.Table)
15631504

15641505
@property
15651506
def texts(self):
1566-
return self.ArtistList(self, 'texts', 'add_artist',
1567-
valid_types=mtext.Text)
1507+
return self.ArtistList(self, 'texts', valid_types=mtext.Text)
15681508

15691509
def get_facecolor(self):
15701510
"""Get the facecolor of the Axes."""

‎lib/matplotlib/backend_bases.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backend_bases.py
+2-13Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1969,7 +1969,7 @@ def leave_notify_event(self, guiEvent=None):
19691969

19701970
@_api.deprecated("3.6", alternative=(
19711971
"callbacks.process('enter_notify_event', LocationEvent(...))"))
1972-
def enter_notify_event(self, guiEvent=None, xy=None):
1972+
def enter_notify_event(self, guiEvent=None, *, xy):
19731973
"""
19741974
Callback processing for the mouse cursor entering the canvas.
19751975
@@ -1983,18 +1983,7 @@ def enter_notify_event(self, guiEvent=None, xy=None):
19831983
xy : (float, float)
19841984
The coordinate location of the pointer when the canvas is entered.
19851985
"""
1986-
if xy is not None:
1987-
x, y = xy
1988-
self._lastx, self._lasty = x, y
1989-
else:
1990-
x = None
1991-
y = None
1992-
_api.warn_deprecated(
1993-
'3.0', removal='3.5', name='enter_notify_event',
1994-
message='Since %(since)s, %(name)s expects a location but '
1995-
'your backend did not pass one. This will become an error '
1996-
'%(removal)s.')
1997-
1986+
self._lastx, self._lasty = x, y = xy
19981987
event = LocationEvent('figure_enter_event', self, x, y, guiEvent)
19991988
self.callbacks.process('figure_enter_event', event)
20001989

‎lib/matplotlib/category.py

Copy file name to clipboardExpand all lines: lib/matplotlib/category.py
-6Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,6 @@ def convert(value, unit, axis):
5858
is_numlike = all(units.ConversionInterface.is_numlike(v)
5959
and not isinstance(v, (str, bytes))
6060
for v in values)
61-
if values.size and is_numlike:
62-
_api.warn_deprecated(
63-
"3.5", message="Support for passing numbers through unit "
64-
"converters is deprecated since %(since)s and support will be "
65-
"removed %(removal)s; use Axis.convert_units instead.")
66-
return np.asarray(values, dtype=float)
6761
# force an update so it also does type checking
6862
unit.update(values)
6963
return np.vectorize(unit._mapping.__getitem__, otypes=[float])(values)

‎lib/matplotlib/legend_handler.py

Copy file name to clipboardExpand all lines: lib/matplotlib/legend_handler.py
+1-25Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
def legend_artist(self, legend, orig_handle, fontsize, handlebox)
2828
"""
2929

30-
from collections.abc import Sequence
3130
from itertools import cycle
3231

3332
import numpy as np
@@ -132,9 +131,6 @@ def legend_artist(self, legend, orig_handle,
132131
xdescent, ydescent, width, height,
133132
fontsize, handlebox.get_transform())
134133

135-
if isinstance(artists, _Line2DHandleList):
136-
artists = [artists[0]]
137-
138134
# create_artists will return a list of artists.
139135
for a in artists:
140136
handlebox.add_artist(a)
@@ -277,24 +273,6 @@ def create_artists(self, legend, orig_handle,
277273
return [legline, legline_marker]
278274

279275

280-
class _Line2DHandleList(Sequence):
281-
def __init__(self, legline):
282-
self._legline = legline
283-
284-
def __len__(self):
285-
return 2
286-
287-
def __getitem__(self, index):
288-
if index != 0:
289-
# Make HandlerLine2D return [self._legline] directly after
290-
# deprecation elapses.
291-
_api.warn_deprecated(
292-
"3.5", message="Access to the second element returned by "
293-
"HandlerLine2D is deprecated since %(since)s; it will be "
294-
"removed %(removal)s.")
295-
return [self._legline, self._legline][index]
296-
297-
298276
class HandlerLine2D(HandlerNpoints):
299277
"""
300278
Handler for `.Line2D` instances.
@@ -331,7 +309,7 @@ def create_artists(self, legend, orig_handle,
331309

332310
legline.set_transform(trans)
333311

334-
return _Line2DHandleList(legline)
312+
return [legline]
335313

336314

337315
class HandlerPatch(HandlerBase):
@@ -790,8 +768,6 @@ def create_artists(self, legend, orig_handle,
790768
_a_list = handler.create_artists(
791769
legend, handle1,
792770
next(xds_cycle), ydescent, width, height, fontsize, trans)
793-
if isinstance(_a_list, _Line2DHandleList):
794-
_a_list = [_a_list[0]]
795771
a_list.extend(_a_list)
796772

797773
return a_list

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.