projects
/
hooke.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
e4373b7
)
Allow fallback to XeX notation for efor extreme powers in ppSI
author
W. Trevor King
<wking@drexel.edu>
Wed, 11 Aug 2010 13:58:09 +0000
(09:58 -0400)
committer
W. Trevor King
<wking@drexel.edu>
Wed, 11 Aug 2010 13:58:09 +0000
(09:58 -0400)
hooke/util/si.py
patch
|
blob
|
history
diff --git
a/hooke/util/si.py
b/hooke/util/si.py
index ac3e633746571177bb1e8c2f83d214fc8704d8de..14d90104494831ab567d0a893b46d5e783700b6b 100644
(file)
--- a/
hooke/util/si.py
+++ b/
hooke/util/si.py
@@
-127,7
+127,11
@@
def ppSI(value, unit='', decimals=None, power=None, pad=False):
# 1 for ' ', 1 for '-', 3 for number, 1 for '.', and decimals.
pad = 6 + decimals
format = lambda n: '%*.*f' % (pad, decimals, n)
- return '%s %s%s' % (format(value / pow(10,power)), PREFIX[power], unit)
+ try:
+ prefix = ' '+PREFIX[power]
+ except KeyError:
+ prefix = 'e%d ' % power
+ return '%s%s%s' % (format(value / pow(10,power)), prefix, unit)
def get_power(value):