@@ -907,8 +907,11 @@ def process_value(value):
907
907
if np .issubdtype (dtype , np .integer ) or dtype .type is np .bool_ :
908
908
# bool_/int8/int16 -> float32; int32/int64 -> float64
909
909
dtype = np .promote_types (dtype , np .float32 )
910
+ # use np.asarray so data passed in as an ndarray subclass are
911
+ # interpreted as an ndarray. See issue #6622.
910
912
result = np .ma .array (value , dtype = dtype , copy = True )
911
- return result , is_scalar
913
+ result_data = np .asarray (result .data )
914
+ return result , result_data , is_scalar
912
915
913
916
def __call__ (self , value , clip = None ):
914
917
"""
@@ -921,12 +924,12 @@ def __call__(self, value, clip=None):
921
924
if clip is None :
922
925
clip = self .clip
923
926
924
- result , is_scalar = self .process_value (value )
927
+ result , resdat , is_scalar = self .process_value (value )
925
928
926
929
self .autoscale_None (result )
927
930
# Convert at least to float, without losing precision.
928
- (vmin ,), _ = self .process_value (self .vmin )
929
- (vmax ,), _ = self .process_value (self .vmax )
931
+ (vmin ,), _ , _ = self .process_value (self .vmin )
932
+ (vmax ,), _ , _ = self .process_value (self .vmax )
930
933
if vmin == vmax :
931
934
result .fill (0 ) # Or should it be all masked? Or 0.5?
932
935
elif vmin > vmax :
@@ -937,9 +940,6 @@ def __call__(self, value, clip=None):
937
940
result = np .ma .array (np .clip (result .filled (vmax ), vmin , vmax ),
938
941
mask = mask )
939
942
# ma division is very slow; we can take a shortcut
940
- # use np.asarray so data passed in as an ndarray subclass are
941
- # interpreted as an ndarray. See issue #6622.
942
- resdat = np .asarray (result .data )
943
943
resdat -= vmin
944
944
resdat /= (vmax - vmin )
945
945
result = np .ma .array (resdat , mask = result .mask , copy = False )
@@ -955,8 +955,8 @@ def __call__(self, value, clip=None):
955
955
def inverse (self , value ):
956
956
if not self .scaled ():
957
957
raise ValueError ("Not invertible until scaled" )
958
- (vmin ,), _ = self .process_value (self .vmin )
959
- (vmax ,), _ = self .process_value (self .vmax )
958
+ (vmin ,), _ , _ = self .process_value (self .vmin )
959
+ (vmax ,), _ , _ = self .process_value (self .vmax )
960
960
961
961
if cbook .iterable (value ):
962
962
val = np .ma .asarray (value )
@@ -991,7 +991,7 @@ def __call__(self, value, clip=None):
991
991
if clip is None :
992
992
clip = self .clip
993
993
994
- result , is_scalar = self .process_value (value )
994
+ result , _ , is_scalar = self .process_value (value )
995
995
996
996
result = np .ma .masked_less_equal (result , 0 , copy = False )
997
997
@@ -1090,7 +1090,7 @@ def __call__(self, value, clip=None):
1090
1090
if clip is None :
1091
1091
clip = self .clip
1092
1092
1093
- result , is_scalar = self .process_value (value )
1093
+ result , resdat , is_scalar = self .process_value (value )
1094
1094
self .autoscale_None (result )
1095
1095
vmin , vmax = self .vmin , self .vmax
1096
1096
@@ -1104,7 +1104,7 @@ def __call__(self, value, clip=None):
1104
1104
result = np .ma .array (np .clip (result .filled (vmax ), vmin , vmax ),
1105
1105
mask = mask )
1106
1106
# in-place equivalent of above can be much faster
1107
- resdat = self ._transform (np . asarray ( result . data ) )
1107
+ resdat = self ._transform (resdat )
1108
1108
resdat -= self ._lower
1109
1109
resdat /= (self ._upper - self ._lower )
1110
1110
@@ -1183,7 +1183,7 @@ def __call__(self, value, clip=None):
1183
1183
if clip is None :
1184
1184
clip = self .clip
1185
1185
1186
- result , is_scalar = self .process_value (value )
1186
+ result , _ , is_scalar = self .process_value (value )
1187
1187
1188
1188
self .autoscale_None (result )
1189
1189
gamma = self .gamma
@@ -1300,7 +1300,7 @@ def __call__(self, value, clip=None):
1300
1300
if clip is None :
1301
1301
clip = self .clip
1302
1302
1303
- xx , is_scalar = self .process_value (value )
1303
+ xx , _ , is_scalar = self .process_value (value )
1304
1304
mask = np .ma .getmaskarray (xx )
1305
1305
xx = np .atleast_1d (xx .filled (self .vmax + 1 ))
1306
1306
if clip :
0 commit comments