Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bce3d7a

Browse files
committed
Minor simplification to Figure.__getstate__ logic.
1 parent 9b48fd8 commit bce3d7a

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

lib/matplotlib/figure.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,14 +1858,11 @@ def __getstate__(self):
18581858
# add version information to the state
18591859
state['__mpl_version__'] = _mpl_version
18601860

1861-
# check to see if the figure has a manager and whether it is registered
1862-
# with pyplot
1863-
if getattr(self.canvas, 'manager', None) is not None:
1864-
manager = self.canvas.manager
1865-
import matplotlib._pylab_helpers
1866-
if manager in list(six.itervalues(
1867-
matplotlib._pylab_helpers.Gcf.figs)):
1868-
state['_restore_to_pylab'] = True
1861+
# check whether the figure manager (if any) is registered with pyplot
1862+
from matplotlib import _pylab_helpers
1863+
if getattr(self.canvas, 'manager', None) \
1864+
in _pylab_helpers.Gcf.figs.values():
1865+
state['_restore_to_pylab'] = True
18691866

18701867
# set all the layoutbox information to None. kiwisolver objects can't
18711868
# be pickled, so we lose the layout options at this point.

0 commit comments

Comments
 (0)