8000 FIX: also account for itertools.count used in _AxesStack · matplotlib/matplotlib@4e0b60c · GitHub
[go: up one dir, main page]

Skip to content

Commit 4e0b60c

Browse files
committed
FIX: also account for itertools.count used in _AxesStack
1 parent c01373c commit 4e0b60c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/matplotlib/figure.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,17 @@ def current(self):
105105
"""Return the active axes, or None if the stack is empty."""
106106
return max(self._axes, key=self._axes.__getitem__, default=None)
107107

108+
def __getstate__(self):
109+
return {
110+
**vars(self),
111+
"_counter": max(self._axes.values(), default=0)
112+
}
113+
114+
def __setstate__(self, state):
115+
next_counter = state.pop('_counter')
116+
vars(self).update(state)
117+
self._counter = itertools.count(next_counter)
118+
108119

109120
class SubplotParams:
110121
"""

0 commit comments

Comments
 (0)
0