gui: cleanup compact_exponential, 15 digits

This commit is contained in:
Robert Jördens 2016-08-11 14:18:27 +02:00
parent 46cae14ab1
commit 92d5491cdc
1 changed files with 9 additions and 7 deletions

View File

@ -96,13 +96,15 @@ class Ticker:
""" """
# this is after the matplotlib ScalarFormatter # this is after the matplotlib ScalarFormatter
# without any i18n # without any i18n
significand, exponent = "{:1.10e}".format(v).split("e") v = "{:.15e}".format(v)
significand = significand.rstrip("0").rstrip(".") if "e" not in v:
exponent_sign = exponent[0].replace("+", "") return v # short number, inf, NaN, -inf
mantissa, exponent = v.split("e")
mantissa = mantissa.rstrip("0").rstrip(".")
exponent_sign = exponent[0].lstrip("+")
exponent = exponent[1:].lstrip("0") exponent = exponent[1:].lstrip("0")
s = "{:s}e{:s}{:s}".format(significand, exponent_sign, return "{:s}e{:s}{:s}".format(mantissa, exponent_sign,
exponent).rstrip("e") exponent).rstrip("e")
return self.fix_minus(s)
def prefix(self, offset, magnitude): def prefix(self, offset, magnitude):
""" """
@ -115,7 +117,7 @@ class Ticker:
prefix += self.compact_exponential(offset) + " + " prefix += self.compact_exponential(offset) + " + "
if magnitude != 1.: if magnitude != 1.:
prefix += self.compact_exponential(magnitude) + " × " prefix += self.compact_exponential(magnitude) + " × "
return prefix return self.fix_minus(prefix)
def __call__(self, a, b): def __call__(self, a, b):
""" """