Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7566447

Browse files
committed
MNT: clean up exponents in simpler way
Makes sure that there are never trailing 'e' with no exponent.
1 parent 7e3ef7d commit 7566447

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/matplotlib/ticker.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -731,13 +731,15 @@ def pprint_val(self, x, d):
731731
else:
732732
fmt = '%1.3f'
733733
s = fmt % x
734-
#print d, x, fmt, s
734+
735735
tup = s.split('e')
736736
if len(tup) == 2:
737737
mantissa = tup[0].rstrip('0').rstrip('.')
738-
sign = tup[1][0].replace('+', '')
739-
exponent = tup[1][1:].lstrip('0')
740-
s = '%se%s%s' % (mantissa, sign, exponent)
738+
exponent = int(tup[1])
739+
if exponent:
740+
s = '%se%d' % (mantissa, exponent)
741+
else:
742+
s = mantissa
741743
else:
742744
s = s.rstrip('0').rstrip('.')
743745
return s

0 commit comments

Comments
 (0)