@@ -1253,43 +1253,31 @@ def format_eng(self, num):
12531253 '1.0 M'
12541254
12551255 >>> format_eng("-1e-6") # for self.places = 2
1256- u'-1.00 \N{GREEK SMALL LETTER MU} '
1257-
1258- `num` may be a numeric value or a string that can be converted
1259- to a numeric value with ``float(num)``.
1256+ '-1.00 \N{GREEK SMALL LETTER MU} '
12601257 """
1261- if isinstance (num , six .string_types ):
1262- warnings .warn (
1263- "Passing a string as *num* argument is deprecated since"
1264- "Matplotlib 2.1, and is expected to be removed in 2.3." ,
1265- mplDeprecation )
1266-
1267- dnum = float (num )
12681258 sign = 1
12691259 fmt = "g" if self .places is None else ".{:d}f" .format (self .places )
12701260
1271- if dnum < 0 :
1261+ if num < 0 :
12721262 sign = - 1
1273- dnum = - dnum
1263+ num = - num
12741264
1275- if dnum != 0 :
1276- pow10 = int (math .floor (math .log10 (dnum ) / 3 ) * 3 )
1265+ if num != 0 :
1266+ pow10 = int (math .floor (math .log10 (num ) / 3 ) * 3 )
12771267 else :
12781268 pow10 = 0
1279- # Force dnum to zero, to avoid inconsistencies like
1269+ # Force num to zero, to avoid inconsistencies like
12801270 # format_eng(-0) = "0" and format_eng(0.0) = "0"
12811271 # but format_eng(-0.0) = "-0.0"
1282- dnum = 0.0
1272+ num = 0.0
12831273
12841274 pow10 = np .clip (pow10 , min (self .ENG_PREFIXES ), max (self .ENG_PREFIXES ))
12851275
1286- mant = sign * dnum / (10.0 ** pow10 )
1287- # Taking care of the cases like 999.9..., which
1288- # may be rounded to 1000 instead of 1 k. Beware
1289- # of the corner case of values that are beyond
1276+ mant = sign * num / (10.0 ** pow10 )
1277+ # Taking care of the cases like 999.9..., which may be rounded to 1000
1278+ # instead of 1 k. Beware of the corner case of values that are beyond
12901279 # the range of SI prefixes (i.e. > 'Y').
1291- _fmant = float ("{mant:{fmt}}" .format (mant = mant , fmt = fmt ))
1292- if _fmant >= 1000 and pow10 != max (self .ENG_PREFIXES ):
1280+ if float (format (mant , fmt )) >= 1000 and pow10 < max (self .ENG_PREFIXES ):
12931281 mant /= 1000
12941282 pow10 += 3
12951283
0 commit comments