aboutsummaryrefslogtreecommitdiff
path: root/src/ee/formatting
diff options
context:
space:
mode:
Diffstat (limited to 'src/ee/formatting')
-rw-r--r--src/ee/formatting/__init__.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/ee/formatting/__init__.py b/src/ee/formatting/__init__.py
index 5e612fe..46e99f7 100644
--- a/src/ee/formatting/__init__.py
+++ b/src/ee/formatting/__init__.py
@@ -8,10 +8,16 @@ __all__ = [
class ESeries(object):
+ ROUND_CLOSEST = 1
+ ROUND_UP = 2
+ ROUND_DOWN = 3
+
def __init__(self, series):
self.series = series
- def closest(self, value):
+ def closest(self, value, round_direction = ROUND_CLOSEST):
+ if round_direction != ESeries.ROUND_CLOSEST:
+ raise NotImplementedError("Only closest rounding is implemented for now")
e = math.floor(math.log10(value))
value = float(value / (10 ** e))
@@ -56,14 +62,6 @@ e48 = ESeries(_e_series_48)
e96 = ESeries(_e_series_96)
e192 = ESeries(_e_series_192)
-
-def e_series_find_closest(value):
- e = math.floor(math.log10(value))
- value = float(value / (10 ** e))
-
- return min(series, key=lambda v: abs(v - value)) * 10 ** e
-
-
import numpy