@@ -442,7 +442,7 @@ def set_data(self, A):
442442 if hasattr (A , 'getpixel' ):
443443 self ._A = pil_to_array (A )
444444 else :
445- self ._A = cbook .safe_masked_invalid (A )
445+ self ._A = cbook .safe_masked_invalid (A , copy = True )
446446
447447 if (self ._A .dtype != np .uint8 and
448448 not np .can_cast (self ._A .dtype , np .float )):
@@ -798,9 +798,9 @@ def set_data(self, x, y, A):
798798 colormapped, or a (M,N,3) RGB array, or a (M,N,4) RGBA
799799 array.
800800 """
801- x = np .asarray (x , np .float32 )
802- y = np .asarray (y , np .float32 )
803- A = cbook .safe_masked_invalid (A )
801+ x = np .array (x , np .float32 )
802+ y = np .array (y , np .float32 )
803+ A = cbook .safe_masked_invalid (A , copy = True )
804804 if len (x .shape ) != 1 or len (y .shape ) != 1 \
805805 or A .shape [0 :2 ] != (y .shape [0 ], x .shape [0 ]):
806806 raise TypeError ("Axes don't match array shape" )
@@ -887,7 +887,8 @@ def __init__(self, ax,
887887 # it needs to be remade if the bbox or viewlim change,
888888 # so caching does help with zoom/pan/resize.
889889 self .update (kwargs )
890- self .set_data (x , y , A )
890+ if A is not None :
891+ self .set_data (x , y , A )
891892
892893 def make_image (self , magnification = 1.0 ):
893894 if self ._A is None :
@@ -938,15 +939,15 @@ def draw(self, renderer, *args, **kwargs):
938939 self .stale = False
939940
940941 def set_data (self , x , y , A ):
941- A = cbook .safe_masked_invalid (A )
942+ A = cbook .safe_masked_invalid (A , copy = True )
942943 if x is None :
943944 x = np .arange (0 , A .shape [1 ]+ 1 , dtype = np .float64 )
944945 else :
945- x = np .asarray (x , np .float64 ).ravel ()
946+ x = np .array (x , np .float64 ).ravel ()
946947 if y is None :
947948 y = np .arange (0 , A .shape [0 ]+ 1 , dtype = np .float64 )
948949 else :
949- y = np .asarray (y , np .float64 ).ravel ()
950+ y = np .array (y , np .float64 ).ravel ()
950951
951952 if A .shape [:2 ] != (y .size - 1 , x .size - 1 ):
952953 print (A .shape )
@@ -1044,7 +1045,8 @@ def get_extent(self):
10441045
10451046 def set_data (self , A ):
10461047 """Set the image array."""
1047- cm .ScalarMappable .set_array (self , cbook .safe_masked_invalid (A ))
1048+ cm .ScalarMappable .set_array (self ,
1049+ cbook .safe_masked_invalid (A , copy = True ))
10481050 self .stale = True
10491051
10501052 def set_array (self , A ):
0 commit comments