From e694329fa6fa8015f62aae6d904e84e5d12bceb5 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Fri, 15 Mar 2024 12:56:07 +0100 Subject: [PATCH] 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). --- lib/matplotlib/tests/test_pickle.py | 3 ++- lib/mpl_toolkits/axes_grid1/axes_size.py | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/matplotlib/tests/test_pickle.py b/lib/matplotlib/tests/test_pickle.py index cab412bff561..7e7ccc14bf8f 100644 --- a/lib/matplotlib/tests/test_pickle.py +++ b/lib/matplotlib/tests/test_pickle.py @@ -15,7 +15,7 @@ import matplotlib.pyplot as plt import matplotlib.transforms as mtransforms import matplotlib.figure as mfigure -from mpl_toolkits.axes_grid1 import parasite_axes # type: ignore +from mpl_toolkits.axes_grid1 import axes_divider, parasite_axes # type: ignore def test_simple(): @@ -274,6 +274,7 @@ def test_unpickle_canvas(): def test_mpl_toolkits(): ax = parasite_axes.host_axes([0, 0, 1, 1]) + axes_divider.make_axes_area_auto_adjustable(ax) assert type(pickle.loads(pickle.dumps(ax))) == parasite_axes.HostAxes diff --git a/lib/mpl_toolkits/axes_grid1/axes_size.py b/lib/mpl_toolkits/axes_grid1/axes_size.py index d25147207726..e417c1a899ac 100644 --- a/lib/mpl_toolkits/axes_grid1/axes_size.py +++ b/lib/mpl_toolkits/axes_grid1/axes_size.py @@ -233,14 +233,14 @@ class _AxesDecorationsSize(_Base): } def __init__(self, ax, direction): - self._get_size = _api.check_getitem( - self._get_size_map, direction=direction) + _api.check_in_list(self._get_size_map, direction=direction) + self._direction = direction self._ax_list = [ax] if isinstance(ax, Axes) else ax def get_size(self, renderer): sz = max([ - self._get_size(ax.get_tightbbox(renderer, call_axes_locator=False), - ax.bbox) + self._get_size_map[self._direction]( + ax.get_tightbbox(renderer, call_axes_locator=False), ax.bbox) for ax in self._ax_list]) dpi = renderer.points_to_pixels(72) abs_size = sz / dpi pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy