@@ -974,30 +974,27 @@ def inverse(self, value):
974
974
return vmin + value * (vmax - vmin )
975
975
976
976
def autoscale (self , A ):
977
- """
978
- Set *vmin*, *vmax* to min, max of *A*.
979
- """
977
+ """Set *vmin*, *vmax* to min, max of *A*."""
980
978
A = np .asanyarray (A )
981
979
self .vmin = A .min ()
982
980
self .vmax = A .max ()
983
981
984
982
def autoscale_None (self , A ):
985
- """autoscale only None-valued vmin or vmax."""
983
+ """Autoscale only None-valued vmin or vmax."""
986
984
A = np .asanyarray (A )
987
985
if self .vmin is None and A .size :
988
986
self .vmin = A .min ()
989
987
if self .vmax is None and A .size :
990
988
self .vmax = A .max ()
991
989
992
990
def scaled (self ):
993
- 'return true if vmin and vmax set'
994
- return ( self .vmin is not None and self .vmax is not None )
991
+ """Return whether vmin and vmax are set."""
992
+ return self .vmin is not None and self .vmax is not None
995
993
996
994
997
995
class LogNorm (Normalize ):
998
- """
999
- Normalize a given value to the 0-1 range on a log scale
1000
- """
996
+ """Normalize a given value to the 0-1 range on a log scale."""
997
+
1001
998
def __call__ (self , value , clip = None ):
1002
999
if clip is None :
1003
1000
clip = self .clip
@@ -1047,22 +1044,10 @@ def inverse(self, value):
1047
1044
return vmin * pow ((vmax / vmin ), value )
1048
1045
1049
1046
def autoscale (self , A ):
1050
- """
1051
- Set *vmin*, *vmax* to min, max of *A*.
1052
- """
1053
- A = np .ma .masked_less_equal (A , 0 , copy = False )
1054
- self .vmin = np .ma .min (A )
1055
- self .vmax = np .ma .max (A )
1047
+ super ().autoscale (np .ma .masked_less_equal (A , 0 , copy = False ))
1056
1048
1057
1049
def autoscale_None (self , A ):
1058
- """autoscale only None-valued vmin or vmax."""
1059
- if self .vmin is not None and self .vmax is not None :
1060
- return
1061
- A = np .ma .masked_less_equal (A , 0 , copy = False )
1062
- if self .vmin is None and A .size :
1063
- self .vmin = A .min ()
1064
- if self .vmax is None and A .size :
1065
- self .vmax = A .max ()
1050
+ super ().autoscale_None (np .ma .masked_less_equal (A , 0 , copy = False ))
1066
1051
1067
1052
1068
1053
class SymLogNorm (Normalize ):
@@ -1124,9 +1109,7 @@ def __call__(self, value, clip=None):
1124
1109
return result
1125
1110
1126
1111
def _transform (self , a ):
1127
- """
1128
- Inplace transformation.
1129
- """
1112
+ """Inplace transformation."""
1130
1113
with np .errstate (invalid = "ignore" ):
1131
1114
masked = np .abs (a ) > self .linthresh
1132
1115
sign = np .sign (a [masked ])
@@ -1137,9 +1120,7 @@ def _transform(self, a):
1137
1120
return a
1138
1121
1139
1122
def _inv_transform (self , a ):
1140
- """
1141
- Inverse inplace Transformation.
1142
- """
1123
+ """Inverse inplace Transformation."""
1143
1124
masked = np .abs (a ) > (self .linthresh * self ._linscale_adj )
1144
1125
sign = np .sign (a [masked ])
1145
1126
exp = np .exp (sign * a [masked ] / self .linthresh - self ._linscale_adj )
@@ -1149,9 +1130,7 @@ def _inv_transform(self, a):
1149
1130
return a
1150
1131
1151
1132
def _transform_vmin_vmax (self ):
1152
- """
1153
- Calculates vmin and vmax in the transformed system.
1154
- """
1133
+ """Calculates vmin and vmax in the transformed system."""
1155
1134
vmin , vmax = self .vmin , self .vmax
1156
1135
arr = np .array ([vmax , vmin ]).astype (float )
1157
1136
self ._upper , self ._lower = self ._transform (arr )
@@ -1164,22 +1143,11 @@ def inverse(self, value):
1164
1143
return self ._inv_transform (val )
1165
1144
1166
1145
def autoscale (self , A ):
1167
- """
1168
- Set *vmin*, *vmax* to min, max of *A*.
1169
- """
1170
- self .vmin = np .ma .min (A )
1171
- self .vmax = np .ma .max (A )
1146
+ super ().autoscale (A )
1172
1147
self ._transform_vmin_vmax ()
1173
1148
1174
1149
def autoscale_None (self , A ):
1175
- """autoscale only None-valued vmin or vmax."""
1176
- if self .vmin is not None and self .vmax is not None :
1177
- pass
1178
- A = np .asanyarray (A )
1179
- if self .vmin is None and A .size :
1180
- self .vmin = A .min ()
1181
- if self .vmax is None and A .size :
1182
- self .vmax = A .max ()
1150
+ super ().autoscale_None (A )
1183
1151
self ._transform_vmin_vmax ()
1184
1152
1185
1153
@@ -1233,34 +1201,17 @@ def inverse(self, value):
1233
1201
else :
1234
1202
return pow (value , 1. / gamma ) * (vmax - vmin ) + vmin
1235
1203
1236
- def autoscale (self , A ):
1237
- """
1238
- Set *vmin*, *vmax* to min, max of *A*.
1239
- """
1240
- self .vmin = np .ma .min (A )
1241
- self .vmax = np .ma .max (A )
1242
-
1243
- def autoscale_None (self , A ):
1244
- """autoscale only None-valued vmin or vmax."""
1245
- A = np .asanyarray (A )
1246
- if self .vmin is None and A .size :
1247
- self .vmin = A .min ()
1248
- if self .vmax is None and A .size :
1249
- self .vmax = A .max ()
1250
-
1251
1204
1252
1205
class BoundaryNorm (Normalize ):
1253
1206
"""
1254
1207
Generate a colormap index based on discrete intervals.
1255
1208
1256
- Unlike :class:`Normalize` or :class:`LogNorm`,
1257
- :class:`BoundaryNorm` maps values to integers instead of to the
1258
- interval 0-1.
1209
+ Unlike `Normalize` or `LogNorm`, `BoundaryNorm` maps values to integers
1210
+ instead of to the interval 0-1.
1259
1211
1260
- Mapping to the 0-1 interval could have been done via
1261
- piece-wise linear interpolation, but using integers seems
1262
- simpler, and reduces the number of conversions back and forth
1263
- between integer and floating point.
1212
+ Mapping to the 0-1 interval could have been done via piece-wise linear
1213
+ interpolation, but using integers seems simpler, and reduces the number of
1214
+ conversions back and forth between integer and floating point.
1264
1215
"""
1265
1216
def __init__ (self , boundaries , ncolors , clip = False ):
1266
1217
"""
@@ -1337,9 +1288,8 @@ def inverse(self, value):
1337
1288
1338
1289
class NoNorm (Normalize ):
1339
1290
"""
1340
- Dummy replacement for Normalize, for the case where we
1341
- want to use indices directly in a
1342
- :class:`~matplotlib.cm.ScalarMappable` .
1291
+ Dummy replacement for Normalize, for the case where we want to use indices
1292
+ directly in a `~matplotlib.cm.ScalarMappable`.
1343
1293
"""
1344
1294
def __call__ (self , value , clip = None ):
1345
1295
return value
0 commit comments