File tree 2 files changed +12
-1
lines changed
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -1999,7 +1999,7 @@ def __setstate__(self, state):
1999
1999
2000
2000
# re-initialise some of the unstored state information
2001
2001
self ._axobservers = []
2002
- self . canvas = None
2002
+ FigureCanvasBase ( self ) # Set self.canvas.
2003
2003
self ._layoutbox = None
2004
2004
2005
2005
if restore_to_pylab :
Original file line number Diff line number Diff line change 10
10
from matplotlib .dates import rrulewrapper
11
11
import matplotlib .pyplot as plt
12
12
import matplotlib .transforms as mtransforms
13
+ import matplotlib .figure as mfigure
13
14
14
15
15
16
def test_simple ():
@@ -194,3 +195,13 @@ def test_shared():
194
195
@pytest .mark .parametrize ("cmap" , cm .cmap_d .values ())
195
196
def test_cmap (cmap ):
196
197
pickle .dumps (cmap )
198
+
199
+
200
+ def test_unpickle_canvas ():
201
+ fig = mfigure .Figure ()
202
+ assert fig .canvas is not None
203
+ out = BytesIO ()
204
+ pickle .dump (fig , out )
205
+ out .seek (0 )
206
+ fig2 = pickle .load (out )
207
+ assert fig2 .canvas is not None
You can’t perform that action at this time.
0 commit comments