Skip to content

Commit a78a3d8

Browse files
committed
MNT: Remove remaining 3.7 deprecations
Not sure why I missed listing these in #26865.
1 parent 47c96df commit a78a3d8

File tree

5 files changed

+18
-20
lines changed

5 files changed

+18
-20
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
``legend.legendHandles``
2+
~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
... was undocumented and has been renamed to ``legend_handles``.
5+
6+
Passing undefined *label_mode* to ``Grid``
7+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8+
9+
... is no longer allowed. This includes `mpl_toolkits.axes_grid1.axes_grid.Grid`,
10+
`mpl_toolkits.axes_grid1.axes_grid.AxesGrid`, and
11+
`mpl_toolkits.axes_grid1.axes_grid.ImageGrid` as well as the corresponding classes
12+
imported from `mpl_toolkits.axisartist.axes_grid`.
13+
14+
Pass ``label_mode='keep'`` instead to get the previous behavior of not modifying labels.

lib/matplotlib/legend.py

-3
Original file line numberDiff line numberDiff line change
@@ -633,9 +633,6 @@ def __init__(
633633
else:
634634
raise ValueError(f"Invalid labelcolor: {labelcolor!r}")
635635

636-
legendHandles = _api.deprecated('3.7', alternative="legend_handles")(
637-
property(lambda self: self.legend_handles))
638-
639636
def _set_artist_props(self, a):
640637
"""
641638
Set the boilerplate props for artists added to Axes.

lib/matplotlib/legend.pyi

-2
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,3 @@ class Legend(Artist):
150150
update: Literal["loc", "bbox"] = ...,
151151
) -> None: ...
152152
def get_draggable(self) -> bool: ...
153-
@property
154-
def legendHandles(self) -> list[Artist | None]: ...

lib/mpl_toolkits/axes_grid1/axes_grid.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ def set_label_mode(self, mode):
234234
- "all": All axes are labelled.
235235
- "keep": Do not do anything.
236236
"""
237+
_api.check_in_list(["all", "L", "1", "keep"], mode=mode)
237238
is_last_row, is_first_col = (
238239
np.mgrid[:self._nrows, :self._ncols] == [[[self._nrows - 1]], [[0]]])
239240
if mode == "all":
@@ -244,15 +245,6 @@ def set_label_mode(self, mode):
244245
elif mode == "1":
245246
bottom = left = is_last_row & is_first_col
246247
else:
247-
# Use _api.check_in_list at the top of the method when deprecation
248-
# period expires
249-
if mode != 'keep':
250-
_api.warn_deprecated(
251-
'3.7', name="Grid label_mode",
252-
message='Passing an undefined label_mode is deprecated '
253-
'since %(since)s and will become an error '
254-
'%(removal)s. To silence this warning, pass '
255-
'"keep", which gives the same behaviour.')
256248
return
257249
for i in range(self._nrows):
258250
for j in range(self._ncols):

lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -432,13 +432,10 @@ def test_image_grid_single_bottom():
432432
grid.cbar_axes[0].colorbar(im)
433433

434434

435-
def test_image_grid_label_mode_deprecation_warning():
436-
imdata = np.arange(9).reshape((3, 3))
437-
435+
def test_image_grid_label_mode_invalid():
438436
fig = plt.figure()
439-
with pytest.warns(mpl.MatplotlibDeprecationWarning,
440-
match="Passing an undefined label_mode"):
441-
grid = ImageGrid(fig, (0, 0, 1, 1), (2, 1), label_mode="foo")
437+
with pytest.raises(ValueError, match="'foo' is not a valid value for mode"):
438+
ImageGrid(fig, (0, 0, 1, 1), (2, 1), label_mode="foo")
442439

443440

444441
@image_comparison(['image_grid.png'],

0 commit comments

Comments
 (0)