From 6c5cbf09021e1571f7128ad7b782e5b13d79a8e1 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 11 Aug 2010 09:58:09 -0400 Subject: [PATCH] Allow fallback to XeX notation for efor extreme powers in ppSI --- hooke/util/si.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hooke/util/si.py b/hooke/util/si.py index ac3e633..14d9010 100644 --- 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): -- 2.26.2