@@ -907,7 +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
- result = np .ma .array (value , dtype = dtype , copy = True )
910
+ # ensure data passed in as an ndarray subclass are interpreted as
911
+ # an ndarray. See issue #6622.
912
+ mask = np .ma .getmask (value )
913
+ data = np .asarray (np .ma .getdata (value ))
914
+ result = np .ma .array (data , mask = mask , dtype = dtype , copy = True )
911
915
return result , is_scalar
912
916
913
917
def __call__ (self , value , clip = None ):
@@ -937,9 +941,7 @@ def __call__(self, value, clip=None):
937
941
result = np .ma .array (np .clip (result .filled (vmax ), vmin , vmax ),
938
942
mask = mask )
939
943
# 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 )
944
+ resdat = result .data
943
945
resdat -= vmin
944
946
resdat /= (vmax - vmin )
945
947
result = np .ma .array (resdat , mask = result .mask , copy = False )
@@ -1007,7 +1009,7 @@ def __call__(self, value, clip=None):
1007
1009
if clip :
1008
1010
mask = np .ma .getmask (result )
1009
1011
result = np .ma .array (np .clip (result .filled (vmax ), vmin , vmax ),
1010
- mask = mask )
1012
+ mask = mask )
1011
1013
# in-place equivalent of above can be much faster
1012
1014
resdat = result .data
1013
1015
mask = result .mask
0 commit comments