10000 stop mixing C-style and format-based formatting · matplotlib/matplotlib@7f1422c · GitHub
[go: up one dir, main page]

Skip to content

Commit 7f1422c

Browse files
committed
stop mixing C-style and format-based formatting
1 parent cd2ac88 commit 7f1422c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/matplotlib/ticker.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,16 +1285,16 @@ def format_eng(self, num):
12851285

12861286
mant = sign * dnum / (10 ** pow10)
12871287

1288-
# TODO: shouldn't we raise a warning if self.places < 0?
12891288
if self.places is None:
1290-
format_str = "%g{sep:s}%s".format(sep=self.sep)
1289+
fmt = "g"
12911290
elif self.places == 0:
1292-
format_str = "%d{sep:s}%s".format(sep=self.sep)
1293-
elif self.places > 0:
1294-
format_str = "%.{p:d}f{sep:s}%s".format(p=self.places,
1295-
sep=self.sep)
1291+
fmt = "d"
1292+
else:
1293+
fmt = ".{}f".format(self.places)
1294+
1295+
formatted = "{mant:{fmt}}{sep}{prefix}".format(
1296+
mant=mant, fmt=fmt, sep=self.sep, prefix=prefix)
12961297

1297-
formatted = format_str % (mant, prefix)
12981298

12991299
return formatted
13001300

0 commit comments

Comments
 (0)
0