@@ -811,8 +811,9 @@ def process_value(value):
811
811
if is_scalar :
812
812
value = [value ]
813
813
dtype = np .min_scalar_type (value )
814
- dtype = (np .float32 if dtype .itemsize <= 2
815
- else np .promote_types (dtype , float ))
814
+ if np .issubdtype (dtype , np .integer ) or dtype .type is np .bool_ :
815
+ # bool_/int8/int16 -> float32; int32/int64 -> float64
816
+ dtype = np .promote_types (dtype , np .float32 )
816
817
result = np .ma .array (value , dtype = dtype , copy = True )
817
818
return result , is_scalar
818
819
@@ -830,7 +831,9 @@ def __call__(self, value, clip=None):
830
831
result , is_scalar = self .process_value (value )
831
832
832
833
self .autoscale_None (result )
833
- vmin , vmax = self .vmin , self .vmax
834
+ # Convert at least to float, without losing precision.
835
+ (vmin ,), _ = self .process_value (self .vmin )
836
+ (vmax ,), _ = self .process_value (self .vmax )
834
837
if vmin == vmax :
835
838
result .fill (0 ) # Or should it be all masked? Or 0.5?
836
839
elif vmin > vmax :
@@ -854,7 +857,8 @@ def __call__(self, value, clip=None):
854
857
def inverse (self , value ):
855
858
if not self .scaled ():
856
859
raise ValueError ("Not invertible until scaled" )
857
- vmin , vmax = self .vmin , self .vmax
860
+ (vmin ,), _ = self .process_value (self .vmin )
861
+ (vmax ,), _ = self .process_value (self .vmax )
858
862
859
863
if cbook .iterable (value ):
860
864
val = ma .asarray (value )
0 commit comments