Skip to content

Commit

Permalink
gui: cleanup compact_exponential, 15 digits
Browse files Browse the repository at this point in the history
jordens committed Aug 11, 2016
1 parent 46cae14 commit 92d5491
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions artiq/gui/ticker.py
Original file line number Diff line number Diff line change
@@ -96,13 +96,15 @@ def compact_exponential(self, v):
"""
# this is after the matplotlib ScalarFormatter
# without any i18n
significand, exponent = "{:1.10e}".format(v).split("e")
significand = significand.rstrip("0").rstrip(".")
exponent_sign = exponent[0].replace("+", "")
v = "{:.15e}".format(v)
if "e" not in v:
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")
s = "{:s}e{:s}{:s}".format(significand, exponent_sign,
exponent).rstrip("e")
return self.fix_minus(s)
return "{:s}e{:s}{:s}".format(mantissa, exponent_sign,
exponent).rstrip("e")

def prefix(self, offset, magnitude):
"""
@@ -115,7 +117,7 @@ def prefix(self, offset, magnitude):
prefix += self.compact_exponential(offset) + " + "
if magnitude != 1.:
prefix += self.compact_exponential(magnitude) + " × "
return prefix
return self.fix_minus(prefix)

def __call__(self, a, b):
"""

0 comments on commit 92d5491

Please sign in to comment.