@@ -1033,46 +1033,14 @@ def __call__(self, value, clip=None):
1033
1033
result = ma .array (np .clip (result .filled (vmax ), vmin , vmax ),
1034
1034
mask = mask )
1035
1035
1036
- # ma division is very slow; we can take a shortcut
1037
- resdat = result .data
1038
-
1039
- #First scale to -1 to 1 range, than to from 0 to 1.
1040
- resdat -= vcenter
1041
- resdat [resdat > 0 ] /= abs (vmax - vcenter )
1042
- resdat [resdat < 0 ] /= abs (vmin - vcenter )
1043
-
1044
- resdat /= 2.
1045
- resdat += 0.5
1046
- result = np .ma .array (resdat , mask = result .mask , copy = False )
1036
+ x , y = [vmin , vcenter , vmax ], [0 , 0.5 , 1 ]
1037
+ result = np .ma .masked_array (np .interp (value , x , y ))
1047
1038
1048
1039
if is_scalar :
1049
1040
result = result [0 ]
1050
1041
1051
1042
return result
1052
1043
1053
- def inverse (self , value ):
1054
- if not self .scaled ():
1055
- raise ValueError ("Not invertible until scaled" )
1056
-
1057
- vmin , vcenter , vmax = self .vmin , self .vcenter , self .vmax
1058
- vmin = float (self .vmin )
1059
- vcenter = float (self .vcenter )
1060
- vmax = float (self .vmax )
1061
-
1062
- if cbook .iterable (value ):
1063
- val = ma .asarray (value )
1064
- val = 2 * (val - 0.5 )
1065
- val [val > 0 ] *= abs (vmax - vcenter )
1066
- val [val < 0 ] *= abs (vmin - vcenter )
1067
- val += vcenter
1068
- return val
1069
- else :
1070
- val = 2 * (val - 0.5 )
1071
- if val < 0 :
1072
- return val * abs (vmin - vcenter ) + vcenter
1073
- else :
1074
- return val * abs (vmax - vcenter ) + vcenter
1075
-
1076
1044
def autoscale_None (self , A ):
1077
1045
' autoscale only None-valued vmin or vmax'
1078
1046
if self .vmin is None and np .size (A ) > 0 :
0 commit comments