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

Skip to content

MNT: Remove remaining 3.7 deprecations #27968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions doc/api/next_api_changes/removals/27968-ES.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
``legend.legendHandles``
~~~~~~~~~~~~~~~~~~~~~~~~

... was undocumented and has been renamed to ``legend_handles``.

Passing undefined *label_mode* to ``Grid``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

... is no longer allowed. This includes `mpl_toolkits.axes_grid1.axes_grid.Grid`,
`mpl_toolkits.axes_grid1.axes_grid.AxesGrid`, and
`mpl_toolkits.axes_grid1.axes_grid.ImageGrid` as well as the corresponding classes
imported from `mpl_toolkits.axisartist.axes_grid`.

Pass ``label_mode='keep'`` instead to get the previous behavior of not modifying labels.
3 changes: 0 additions & 3 deletions lib/matplotlib/legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,9 +633,6 @@ def __init__(
else:
raise ValueError(f"Invalid labelcolor: {labelcolor!r}")

legendHandles = _api.deprecated('3.7', alternative="legend_handles")(
property(lambda self: self.legend_handles))

def _set_artist_props(self, a):
"""
Set the boilerplate props for artists added to Axes.
Expand Down
2 changes: 0 additions & 2 deletions lib/matplotlib/legend.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,3 @@ class Legend(Artist):
update: Literal["loc", "bbox"] = ...,
) -> None: ...
def get_draggable(self) -> bool: ...
@property
def legendHandles(self) -> list[Artist | None]: ...
10 changes: 1 addition & 9 deletions lib/mpl_toolkits/axes_grid1/axes_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ def set_label_mode(self, mode):
- "all": All axes are labelled.
- "keep": Do not do anything.
"""
_api.check_in_list(["all", "L", "1", "keep"], mode=mode)
is_last_row, is_first_col = (
np.mgrid[:self._nrows, :self._ncols] == [[[self._nrows - 1]], [[0]]])
if mode == "all":
Expand All @@ -244,15 +245,6 @@ def set_label_mode(self, mode):
elif mode == "1":
bottom = left = is_last_row & is_first_col
else:
# Use _api.check_in_list at the top of the method when deprecation
# period expires
if mode != 'keep':
_api.warn_deprecated(
'3.7', name="Grid label_mode",
message='Passing an undefined label_mode is deprecated '
'since %(since)s and will become an error '
'%(removal)s. To silence this warning, pass '
'"keep", which gives the same behaviour.')
return
for i in range(self._nrows):
for j in range(self._ncols):
Expand Down
9 changes: 3 additions & 6 deletions lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,13 +432,10 @@ def test_image_grid_single_bottom():
grid.cbar_axes[0].colorbar(im)


def test_image_grid_label_mode_deprecation_warning():
imdata = np.arange(9).reshape((3, 3))

def test_image_grid_label_mode_invalid():
fig = plt.figure()
with pytest.warns(mpl.MatplotlibDeprecationWarning,
match="Passing an undefined label_mode"):
grid = ImageGrid(fig, (0, 0, 1, 1), (2, 1), label_mode="foo")
with pytest.raises(ValueError, match="'foo' is not a valid value for mode"):
ImageGrid(fig, (0, 0, 1, 1), (2, 1), label_mode="foo")


@image_comparison(['image_grid.png'],
Expand Down