8000 Fix pickling of make_axes_area_auto_adjustable'd axes. · matplotlib/matplotlib@e694329 · GitHub
[go: up one dir, main page]

Skip to content

Commit e694329

Browse files
committed
Fix pickling of make_axes_area_auto_adjustable'd axes.
... by not storing a lambda in the _AxesDecorationsSize instance, just a name (the dict lookup cost should be negligible compare to the rest).
1 parent bcee01f commit e694329

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

lib/matplotlib/tests/test_pickle.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import matplotlib.pyplot as plt
1616
import matplotlib.transforms as mtransforms
1717
import matplotlib.figure as mfigure
18-
from mpl_toolkits.axes_grid1 import parasite_axes # type: ignore
18+
from mpl_toolkits.axes_grid1 import axes_divider, parasite_axes # type: ignore
1919

2020

2121
def test_simple():
@@ -274,6 +274,7 @@ def test_unpickle_canvas():
274274

275275
def test_mpl_toolkits():
276276
ax = parasite_axes.host_axes([0, 0, 1, 1])
277+
axes_divider.make_axes_area_auto_adjustable(ax)
277278
assert type(pickle.loads(pickle.dumps(ax))) == parasite_axes.HostAxes
278279

279280

lib/mpl_toolkits/axes_grid1/axes_size.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,14 +233,14 @@ class _AxesDecorationsSize(_Base):
233233
}
234234

235235
def __init__(self, ax, direction):
236-
self._get_size = _api.check_getitem(
237-
self._get_size_map, direction=direction)
236+
_api.check_in_list(self._get_size_map, direction=direction)
237+
self._direction = direction
238238
self._ax_list = [ax] if isinstance(ax, Axes) else ax
239239

240240
def get_size(self, renderer):
241241
sz = max([
242-
self._get_size(ax.get_tightbbox(renderer, call_axes_locator=False),
243-
ax.bbox)
242+
self._get_size_map[self._direction](
243+
ax.get_tightbbox(renderer, call_axes_locator=False), ax.bbox)
244244
for ax in self._ax_list])
245245
dpi = renderer.points_to_pixels(72)
246246
abs_size = sz / dpi

0 commit comments

Comments
 (0)
0