Skip to content

Commit 5398657

Browse files
authored
Merge pull request #22098 from anntzer/mpltk36
Expire axes_grid1/axisartist deprecations.
2 parents 9e9dccc + 7749b7b commit 5398657

File tree

9 files changed

+21
-134
lines changed

9 files changed

+21
-134
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
``axes_grid`` and ``axisartist`` removals
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
The following deprecated APIs have been removed:
5+
6+
- ``SubplotDivider.figbox``, ``SubplotDivider.update_params``,
7+
- ``SubplotDivider.get_geometry`` (use ``get_subplotspec`` instead),
8+
- ``change_geometry`` (use ``set_subplotspec`` instead),
9+
- ``ParasiteAxesBase.update_viewlim`` (use ``apply_aspect`` instead),
10+
- ``ParasiteAxesAuxTransBase`` (use ``ParasiteAxesBase`` instead),
11+
- ``parasite_axes_auxtrans_class_factory`` (use ``parasite_axes_class_factory``
12+
instead),
13+
- ``ParasiteAxesAuxTrans`` (use ``ParasiteAxes`` instead),
+1-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
from matplotlib import _api
21
from mpl_toolkits.axes_grid1.parasite_axes import (
32
host_axes_class_factory, parasite_axes_class_factory,
4-
parasite_axes_auxtrans_class_factory, subplot_class_factory)
3+
subplot_class_factory)
54
from mpl_toolkits.axisartist.axislines import Axes
65

76

87
ParasiteAxes = parasite_axes_class_factory(Axes)
98
HostAxes = host_axes_class_factory(Axes)
109
SubplotHost = subplot_class_factory(HostAxes)
11-
with _api.suppress_matplotlib_deprecation_warning():
12-
ParasiteAxesAuxTrans = parasite_axes_auxtrans_class_factory(ParasiteAxes)

lib/mpl_toolkits/axes_grid1/axes_divider.py

+1-25
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import matplotlib as mpl
88
from matplotlib import _api
99
from matplotlib.axes import SubplotBase
10-
from matplotlib.gridspec import SubplotSpec, GridSpec
10+
from matplotlib.gridspec import SubplotSpec
1111
import matplotlib.transforms as mtransforms
1212
from . import axes_size as Size
1313

@@ -368,30 +368,6 @@ def get_position(self):
368368
"""Return the bounds of the subplot box."""
369369
return self.get_subplotspec().get_position(self.figure).bounds
370370

371-
@_api.deprecated("3.4")
372-
@property
373-
def figbox(self):
374-
return self.get_subplotspec().get_position(self.figure)
375-
376-
@_api.deprecated("3.4")
377-
def update_params(self):
378-
pass
379-
380-
@_api.deprecated(
381-
"3.4", alternative="get_subplotspec",
382-
addendum="(get_subplotspec returns a SubplotSpec instance.)")
383-
def get_geometry(self):
384-
"""Get the subplot geometry, e.g., (2, 2, 3)."""
385-
rows, cols, num1, num2 = self.get_subplotspec().get_geometry()
386-
return rows, cols, num1 + 1 # for compatibility
387-
388-
@_api.deprecated("3.4", alternative="set_subplotspec")
389-
def change_geometry(self, numrows, numcols, num):
390-
"""Change subplot geometry, e.g., from (1, 1, 1) to (2, 2, 3)."""
391-
self._subplotspec = GridSpec(numrows, numcols)[num-1]
392-
self.update_params()
393-
self.set_position(self.figbox)
394-
395371
def get_subplotspec(self):
396372
"""Get the SubplotSpec instance."""
397373
return self._subplotspec

lib/mpl_toolkits/axes_grid1/parasite_axes.py

-68
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import functools
2-
31
from matplotlib import _api, cbook
42
import matplotlib.artist as martist
53
import matplotlib.image as mimage
@@ -71,10 +69,6 @@ def set_viewlim_mode(self, mode):
7169
def get_viewlim_mode(self):
7270
return self._viewlim_mode
7371

74-
@_api.deprecated("3.4", alternative="apply_aspect")
75-
def update_viewlim(self):
76-
return self._update_viewlim
77-
7872
def _update_viewlim(self): # Inline after deprecation elapses.
7973
viewlim = self._parent_axes.viewLim.frozen()
8074
mode = self.get_viewlim_mode()
@@ -100,68 +94,6 @@ def apply_aspect(self, position=None):
10094
ParasiteAxes = parasite_axes_class_factory(Axes)
10195

10296

103-
@_api.deprecated("3.4", alternative="ParasiteAxesBase")
104-
class ParasiteAxesAuxTransBase:
105-
def __init__(self, parent_axes, aux_transform, viewlim_mode=None,
106-
**kwargs):
107-
# Explicit wrapper for deprecation to work.
108-
super().__init__(parent_axes, aux_transform,
109-
viewlim_mode=viewlim_mode, **kwargs)
110-
111-
def _set_lim_and_transforms(self):
112-
self.transAxes = self._parent_axes.transAxes
113-
self.transData = self.transAux + self._parent_axes.transData
114-
self._xaxis_transform = mtransforms.blended_transform_factory(
115-
self.transData, self.transAxes)
116-
self._yaxis_transform = mtransforms.blended_transform_factory(
117-
self.transAxes, self.transData)
118-
119-
def set_viewlim_mode(self, mode):
120-
_api.check_in_list([None, "equal", "transform"], mode=mode)
121-
self._viewlim_mode = mode
122-
123-
def get_viewlim_mode(self):
124-
return self._viewlim_mode
125-
126-
@_api.deprecated("3.4", alternative="apply_aspect")
127-
def update_viewlim(self):
128-
return self._update_viewlim()
129-
130-
def _update_viewlim(self): # Inline after deprecation elapses.
131-
viewlim = self._parent_axes.viewLim.frozen()
132-
mode = self.get_viewlim_mode()
133-
if mode is None:
134-
pass
135-
elif mode == "equal":
136-
self.axes.viewLim.set(viewlim)
137-
elif mode == "transform":
138-
self.axes.viewLim.set(
139-
viewlim.transformed(self.transAux.inverted()))
140-
else:
141-
_api.check_in_list([None, "equal", "transform"], mode=mode)
142-
143-
def apply_aspect(self, position=None):
144-
self._update_viewlim()
145-
super().apply_aspect()
146-
147-
148-
@_api.deprecated("3.4", alternative="parasite_axes_class_factory")
149-
@functools.lru_cache(None)
150-
def parasite_axes_auxtrans_class_factory(axes_class):
151-
if not issubclass(axes_class, ParasiteAxesBase):
152-
parasite_axes_class = parasite_axes_class_factory(axes_class)
153-
else:
154-
parasite_axes_class = axes_class
155-
return type("%sParasiteAuxTrans" % parasite_axes_class.__name__,
156-
(ParasiteAxesAuxTransBase, parasite_axes_class),
157-
{'name': 'parasite_axes'})
158-
159-
160-
# Also deprecated.
161-
with _api.suppress_matplotlib_deprecation_warning():
162-
ParasiteAxesAuxTrans = parasite_axes_auxtrans_class_factory(ParasiteAxes)
163-
164-
16597
class HostAxesBase:
16698
def __init__(self, *args, **kwargs):
16799
self.parasites = []
+1-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from matplotlib import _api
21
from .axislines import (
32
Axes, AxesZero, AxisArtistHelper, AxisArtistHelperRectlinear,
43
GridHelperBase, GridHelperRectlinear, Subplot, SubplotZero)
@@ -7,11 +6,9 @@
76
from .floating_axes import FloatingAxes, FloatingSubplot
87
from mpl_toolkits.axes_grid1.parasite_axes import (
98
host_axes_class_factory, parasite_axes_class_factory,
10-
parasite_axes_auxtrans_class_factory, subplot_class_factory)
9+
subplot_class_factory)
1110

1211

1312
ParasiteAxes = parasite_axes_class_factory(Axes)
1413
HostAxes = host_axes_class_factory(Axes)
1514
SubplotHost = subplot_class_factory(HostAxes)
16-
with _api.suppress_matplotlib_deprecation_warning():
17-
ParasiteAxesAuxTrans = parasite_axes_auxtrans_class_factory(ParasiteAxes)

lib/mpl_toolkits/axisartist/axis_artist.py

-5
Original file line numberDiff line numberDiff line change
@@ -621,11 +621,6 @@ class AxisArtist(martist.Artist):
621621

622622
zorder = 2.5
623623

624-
@_api.deprecated("3.4")
625-
@_api.classproperty
626-
def ZORDER(cls):
627-
return cls.zorder
628-
629624
@property
630625
def LABELPAD(self):
631626
return self.label.get_pad()

lib/mpl_toolkits/axisartist/axislines.py

+1-15
Original file line numberDiff line numberDiff line change
@@ -315,29 +315,19 @@ def _f(locs, labels):
315315
class GridHelperBase:
316316

317317
def __init__(self):
318-
self._force_update = True # Remove together with invalidate()/valid().
319318
self._old_limits = None
320319
super().__init__()
321320

322321
def update_lim(self, axes):
323322
x1, x2 = axes.get_xlim()
324323
y1, y2 = axes.get_ylim()
325-
if self._force_update or self._old_limits != (x1, x2, y1, y2):
324+
if self._old_limits != (x1, x2, y1, y2):
326325
self._update_grid(x1, y1, x2, y2)
327-
self._force_update = False
328326
self._old_limits = (x1, x2, y1, y2)
329327

330328
def _update_grid(self, x1, y1, x2, y2):
331329
"""Cache relevant computations when the axes limits have changed."""
332330

333-
@_api.deprecated("3.4")
334-
def invalidate(self):
335-
self._force_update = True
336-
337-
@_api.deprecated("3.4")
338-
def valid(self):
339-
return not self._force_update
340-
341331
def get_gridlines(self, which, axis):
342332
"""
343333
Return list of grid lines as a list of paths (list of points).
@@ -555,10 +545,6 @@ def get_children(self):
555545
children.extend(super().get_children())
556546
return children
557547

558-
@_api.deprecated("3.4")
559-
def invalidate_grid_helper(self):
560-
self._grid_helper.invalidate()
561-
562548
def new_fixed_axis(self, loc, offset=None):
563549
gh = self.get_grid_helper()
564550
axis = gh.new_fixed_axis(loc,
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
from matplotlib import _api
21
from mpl_toolkits.axes_grid1.parasite_axes import (
32
host_axes_class_factory, parasite_axes_class_factory,
4-
parasite_axes_auxtrans_class_factory, subplot_class_factory)
3+
subplot_class_factory)
54
from .axislines import Axes
65

76

87
ParasiteAxes = parasite_axes_class_factory(Axes)
98
HostAxes = host_axes_class_factory(Axes)
109
SubplotHost = subplot_class_factory(HostAxes)
11-
with _api.suppress_matplotlib_deprecation_warning():
12-
ParasiteAxesAuxTrans = parasite_axes_auxtrans_class_factory(ParasiteAxes)

lib/mpl_toolkits/tests/test_axisartist_axislines.py

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
import numpy as np
2-
from matplotlib import _api
32
import matplotlib.pyplot as plt
43
from matplotlib.testing.decorators import image_comparison
54
from matplotlib.transforms import IdentityTransform
65

76
from mpl_toolkits.axisartist.axislines import SubplotZero, Subplot
8-
from mpl_toolkits.axisartist import (
9-
Axes, SubplotHost, ParasiteAxes, ParasiteAxesAuxTrans)
10-
11-
import pytest
7+
from mpl_toolkits.axisartist import Axes, SubplotHost, ParasiteAxes
128

139

1410
@image_comparison(['SubplotZero.png'], style='default')
@@ -61,10 +57,9 @@ def test_Axes():
6157
fig.canvas.draw()
6258

6359

64-
@pytest.mark.parametrize('parasite_cls', [ParasiteAxes, ParasiteAxesAuxTrans])
6560
@image_comparison(['ParasiteAxesAuxTrans_meshplot.png'],
6661
remove_text=True, style='default', tol=0.075)
67-
def test_ParasiteAxesAuxTrans(parasite_cls):
62+
def test_ParasiteAxesAuxTrans():
6863
# Remove this line when this test image is regenerated.
6964
plt.rcParams['pcolormesh.snap'] = False
7065

@@ -86,8 +81,7 @@ def test_ParasiteAxesAuxTrans(parasite_cls):
8681
ax1 = SubplotHost(fig, 1, 3, i+1)
8782
fig.add_subplot(ax1)
8883

89-
with _api.suppress_matplotlib_deprecation_warning():
90-
ax2 = parasite_cls(ax1, IdentityTransform())
84+
ax2 = ParasiteAxes(ax1, IdentityTransform())
9185
ax1.parasites.append(ax2)
9286
if name.startswith('pcolor'):
9387
getattr(ax2, name)(xx, yy, data[:-1, :-1])

0 commit comments

Comments
 (0)