@@ -260,10 +260,8 @@ def __init__(self, ax,
260
260
self .update (kwargs )
261
261
262
262
def __getstate__ (self ):
263
- state = super ().__getstate__ ()
264
- # We can't pickle the C Image cached object.
265
- state ['_imcache' ] = None
266
- return state
263
+ # Save some space on the pickle by not saving the cache.
264
+ return {** super ().__getstate__ (), "_imcache" : None }
267
265
268
266
def get_size (self ):
269
267
"""Return the size of the image as tuple (numrows, numcols)."""
@@ -304,7 +302,6 @@ def changed(self):
304
302
Call this whenever the mappable is changed so observers can update.
305
303
"""
306
304
self ._imcache = None
307
- self ._rgbacache = None
308
305
cm .ScalarMappable .changed (self )
309
306
310
307
def _make_image (self , A , in_bbox , out_bbox , clip_bbox , magnification = 1.0 ,
@@ -710,7 +707,6 @@ def set_data(self, A):
710
707
self ._A = self ._A .astype (np .uint8 )
711
708
712
709
self ._imcache = None
713
- self ._rgbacache = None
714
710
self .stale = True
715
711
716
712
def set_array (self , A ):
@@ -1214,10 +1210,10 @@ def make_image(self, renderer, magnification=1.0, unsampled=False):
1214
1210
if unsampled :
1215
1211
raise ValueError ('unsampled not supported on PColorImage' )
1216
1212
1217
- if self ._rgbacache is None :
1213
+ if self ._imcache is None :
1218
1214
A = self .to_rgba (self ._A , bytes = True )
1219
<
951A
code class="diff-text syntax-highlighted-line deletion">- self ._rgbacache = np .pad (A , [(1 , 1 ), (1 , 1 ), (0 , 0 )], "constant" )
1220
- padded_A = self ._rgbacache
1215
+ self ._imcache = np .pad (A , [(1 , 1 ), (1 , 1 ), (0 , 0 )], "constant" )
1216
+ padded_A = self ._imcache
1221
1217
bg = mcolors .to_rgba (self .axes .patch .get_facecolor (), 0 )
1222
1218
bg = (np .array (bg ) * 255 ).astype (np .uint8 )
1223
1219
if (padded_A [0 , 0 ] != bg ).all ():
@@ -1294,7 +1290,7 @@ def set_data(self, x, y, A):
1294
1290
self ._A = A
1295
1291
self ._Ax = x
1296
1292
self ._Ay = y
1297
- self ._rgbacache = None
1293
+ self ._imcache = None
1298
1294
self .stale = True
1299
1295
1300
1296
def set_array (self , * args ):
0 commit comments