File tree 2 files changed +15
-1
lines changed 2 files changed +15
-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 5
5
import numpy as np
6
6
import pytest
7
7
8
+ import pickle
9
+ import io
10
+
8
11
from matplotlib import cm
9
12
from matplotlib .testing .decorators import image_comparison
10
13
from matplotlib .dates import rrulewrapper
11
14
import matplotlib .pyplot as plt
12
15
import matplotlib .transforms as mtransforms
16
+ import matplotlib .figure as mfigure
13
17
14
18
15
19
def test_simple ():
@@ -194,3 +198,13 @@ def test_shared():
194
198
@pytest .mark .parametrize ("cmap" , cm .cmap_d .values ())
195
199
def test_cmap (cmap ):
196
200
pickle .dumps (cmap )
201
+
202
+
203
+ def test_unpickle_canvas ():
204
+ fig = mfigure .Figure ()
205
+ assert fig .canvas is not None
206
+ out = io .BytesIO ()
207
+ pickle .dump (fig , out )
208
+ out .seek (0 )
209
+ fig2 = pickle .load (out )
210
+ assert fig2 .canvas is not None
You can’t perform that action at this time.
0 commit comments