@@ -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,12 @@ 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
+ # docstring inherited.
1048
+ super ().autoscale (np .ma .masked_less_equal (A , 0 , copy = False ))
1056
1049
1057
1050
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 ()
1051
+ # docstring inherited.
1052
+ super ().autoscale_None (np .ma .masked_less_equal (A , 0 , copy = False ))
1066
1053
1067
1054
1068
1055
class SymLogNorm (Normalize ):
@@ -1124,9 +1111,7 @@ def __call__(self, value, clip=None):
1124
1111
return result
1125
1112
1126
1113
def _transform (self , a ):
1127
- """
1128
- Inplace transformation.
1129
- """
1114
+ """Inplace transformation."""
1130
1115
with np .errstate (invalid = "ignore" ):
1131
1116
masked = np .abs (a ) > self .linthresh
1132
1117
sign = np .sign (a [masked ])
@@ -1137,9 +1122,7 @@ def _transform(self, a):
1137
1122
return a
1138
1123
1139
1124
def _inv_transform (self , a ):
1140
- """
1141
- Inverse inplace Transformation.
1142
- """
1125
+ """Inverse inplace Transformation."""
1143
1126
masked = np .abs (a ) > (self .linthresh * self ._linscale_adj )
1144
1127
sign = np .sign (a [masked ])
1145
1128
exp = np .exp (sign * a [masked ] / self .linthresh - self ._linscale_adj )
@@ -1149,9 +1132,7 @@ def _inv_transform(self, a):
1149
1132
return a
1150
1133
1151
1134
def _transform_vmin_vmax (self ):
1152
- """
1153
- Calculates vmin and vmax in the transformed system.
1154
- """
1135
+ """Calculates vmin and vmax in the transformed system."""
1155
1136
vmin , vmax = self .vmin , self .vmax
1156
1137
arr = np .array ([vmax , vmin ]).astype (float )
1157
1138
self ._upper , self ._lower = self ._transform (arr )
@@ -1164,22 +1145,13 @@ def inverse(self, value):
1164
1145
return self ._inv_transform (val )
1165
1146
1166
1147
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 )
1148
+ # docstring inherited.
1149
+ super ().autoscale (A )
1172
1150
self ._transform_vmin_vmax ()
1173
1151
1174
1152
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 ()
1153
+ # docstring inherited.
1154
+ super ().autoscale_None (A )
1183
1155
self ._transform_vmin_vmax ()
1184
1156
1185
1157
@@ -1233,34 +1205,17 @@ def inverse(self, value):
1233
1205
else :
1234
1206
return pow (value , 1. / gamma ) * (vmax - vmin ) + vmin
1235
1207
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
1208
1252
1209
class BoundaryNorm (Normalize ):
1253
1210
"""
1254
1211
Generate a colormap index based on discrete intervals.
1255
1212
1256
- Unlike :class:`Normalize` or :class:`LogNorm`,
1257
- :class:`BoundaryNorm` maps values to integers instead of to the
1258
- interval 0-1.
1213
+ Unlike `Normalize` or `LogNorm`, `BoundaryNorm` maps values to integers
1214
+ instead of to the interval 0-1.
1259
1215
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.
1216
+ Mapping to the 0-1 interval could have been done via piece-wise linear
1217
+ interpolation, but using integers seems simpler, and reduces the number of
1218
+ conversions back and forth between integer and floating point.
1264
1219
"""
1265
1220
def __init__ (self , boundaries , ncolors , clip = False ):
1266
1221
"""
@@ -1337,9 +1292,8 @@ def inverse(self, value):
1337
1292
1338
1293
class NoNorm (Normalize ):
1339
1294
"""
1340
- Dummy replacement for Normalize, for the case where we
1341
- want to use indices directly in a
1342
- :class:`~matplotlib.cm.ScalarMappable` .
1295
+ Dummy replacement for `Normalize`, for the case where we want to use
1296
+ indices directly in a `~matplotlib.cm.ScalarMappable`.
1343
1297
"""
1344
1298
def __call__ (self , value , clip = None ):
1345
1299
return value
@@ -1350,7 +1304,7 @@ def inverse(self, value):
1350
1304
1351
1305
def rgb_to_hsv (arr ):
1352
1306
"""
1353
- convert float rgb values (in the r
4DDA
ange [0, 1]), in a numpy array to hsv
1307
+ Convert float rgb values (in the range [0, 1]), in a numpy array to hsv
1354
1308
values.
1355
1309
1356
1310
Parameters
0 commit comments