@@ -884,8 +884,9 @@ def process_value(value):
884
884
if is_scalar :
885
885
value = [value ]
886
886
dtype = np .min_scalar_type (value )
887
- dtype = (np .float32 if dtype .itemsize <= 2
888
- else np .promote_types (dtype , float ))
887
+ if np .issubdtype (dtype , np .integer ) or dtype .type is np .bool_ :
888
+ # bool_/int8/int16 -> float32; int32/int64 -> float64
889
+ dtype = np .promote_types (dtype , np .float32 )
889
890
result = np .ma .array (value , dtype = dtype , copy = True )
890
891
return result , is_scalar
891
892
@@ -903,7 +904,9 @@ def __call__(self, value, clip=None):
903
904
result , is_scalar = self .process_value (value )
904
905
905
906
self .autoscale_None (result )
906
- vmin , vmax = self .vmin , self .vmax
907
+ # Convert at least to float, without losing precision.
908
+ (vmin ,), _ = self .process_value (self .vmin )
909
+ (vmax ,), _ = self .process_value (self .vmax )
907
910
if vmin == vmax :
908
911
result .fill (0 ) # Or should it be all masked? Or 0.5?
909
912
elif vmin > vmax :
@@ -927,7 +930,8 @@ def __call__(self, value, clip=None):
927
930
def inverse (self , value ):
928
931
if not self .scaled ():
929
932
raise ValueError ("Not invertible until scaled" )
930
- vmin , vmax = self .vmin , self .vmax
933
+ (vmin ,), _ = self .process_value (self .vmin )
934
+ (vmax ,), _ = self .process_value (self .vmax )
931
935
932
936
if cbook .iterable (value ):
933
937
val = np .ma .asarray (value )
0 commit comments