|
1 |
| -import functools |
2 | 1 | import uuid
|
3 | 2 |
|
4 | 3 | from matplotlib import _api, cbook, docstring
|
@@ -38,15 +37,6 @@ def __init__(self, fig, *args, **kwargs):
|
38 | 37 | # This will also update the axes position.
|
39 | 38 | self.set_subplotspec(SubplotSpec._from_subplot_args(fig, args))
|
40 | 39 |
|
41 |
| - def __reduce__(self): |
42 |
| - # get the first axes class which does not inherit from a subplotbase |
43 |
| - axes_class = next( |
44 |
| - c for c in type(self).__mro__ |
45 |
| - if issubclass(c, Axes) and not issubclass(c, SubplotBase)) |
46 |
| - return (_picklable_subplot_class_constructor, |
47 |
| - (axes_class,), |
48 |
| - self.__getstate__()) |
49 |
| - |
50 | 40 | @_api.deprecated(
|
51 | 41 | "3.4", alternative="get_subplotspec",
|
52 | 42 | addendum="(get_subplotspec returns a SubplotSpec instance.)")
|
@@ -168,58 +158,10 @@ def _make_twin_axes(self, *args, **kwargs):
|
168 | 158 | return twin
|
169 | 159 |
|
170 | 160 |
|
171 |
| -# this here to support cartopy which was using a private part of the |
172 |
| -# API to register their Axes subclasses. |
173 |
| - |
174 |
| -# In 3.1 this should be changed to a dict subclass that warns on use |
175 |
| -# In 3.3 to a dict subclass that raises a useful exception on use |
176 |
| -# In 3.4 should be removed |
177 |
| - |
178 |
| -# The slow timeline is to give cartopy enough time to get several |
179 |
| -# release out before we break them. |
180 |
| -_subplot_classes = {} |
181 |
| - |
182 |
| - |
183 |
| -@functools.lru_cache(None) |
184 |
| -def subplot_class_factory(axes_class=None): |
185 |
| - """ |
186 |
| - Make a new class that inherits from `.SubplotBase` and the |
187 |
| - given axes_class (which is assumed to be a subclass of `.axes.Axes`). |
188 |
| - This is perhaps a little bit roundabout to make a new class on |
189 |
| - the fly like this, but it means that a new Subplot class does |
190 |
| - not have to be created for every type of Axes. |
191 |
| - """ |
192 |
| - if axes_class is None: |
193 |
| - cbook.warn_deprecated( |
194 |
| - "3.3", message="Support for passing None to subplot_class_factory " |
195 |
| - "is deprecated since %(since)s; explicitly pass the default Axes " |
196 |
| - "class instead. This will become an error %(removal)s.") |
197 |
| - axes_class = Axes |
198 |
| - try: |
199 |
| - # Avoid creating two different instances of GeoAxesSubplot... |
200 |
| - # Only a temporary backcompat fix. This should be removed in |
201 |
| - # 3.4 |
202 |
| - return next(cls for cls in SubplotBase.__subclasses__() |
203 |
| - if cls.__bases__ == (SubplotBase, axes_class)) |
204 |
| - except StopIteration: |
205 |
| - return type("%sSubplot" % axes_class.__name__, |
206 |
| - (SubplotBase, axes_class), |
207 |
| - {'_axes_class': axes_class}) |
208 |
| - |
209 |
| - |
| 161 | +subplot_class_factory = cbook._make_class_factory( |
| 162 | + SubplotBase, "{}Subplot", "_axes_class", default_axes_class=Axes) |
210 | 163 | Subplot = subplot_class_factory(Axes) # Provided for backward compatibility.
|
211 | 164 |
|
212 |
| - |
213 |
| -def _picklable_subplot_class_constructor(axes_class): |
214 |
| - """ |
215 |
| - Stub factory that returns an empty instance of the appropriate subplot |
216 |
| - class when called with an axes class. This is purely to allow pickling of |
217 |
| - Axes and Subplots. |
218 |
| - """ |
219 |
| - subplot_class = subplot_class_factory(axes_class) |
220 |
| - return subplot_class.__new__(subplot_class) |
221 |
| - |
222 |
| - |
223 | 165 | docstring.interpd.update(Axes=martist.kwdoc(Axes))
|
224 | 166 | docstring.dedent_interpd(Axes.__init__)
|
225 | 167 |
|
|
0 commit comments