From a60b53a49e2cfa840d37b6c0b72cfe37caf29509 Mon Sep 17 00:00:00 2001 From: pepperpepperpepper Date: Tue, 8 Dec 2015 17:00:56 -0800 Subject: finished normalization, fixing serialization --- ricky/param/enum.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ricky/param/enum.py') diff --git a/ricky/param/enum.py b/ricky/param/enum.py index 137c58e..09a4cc3 100644 --- a/ricky/param/enum.py +++ b/ricky/param/enum.py @@ -41,11 +41,11 @@ class Enum(Param): return my_dict def from_normalized(self, value): - maximum = len(self._options - 1) + maximum = len(self._options) - 1 idx_val = int(round(maximum * value, 0)) self.value = self._options[idx_val] def as_normalized(self): - maximum = len(self._options - 1) - value = int(self.as_hex(), 16) + maximum = len(self._options) - 1 + value = self._options.index(self.value) return decimal.Decimal(value)/decimal.Decimal(maximum) -- cgit v1.2.3-70-g09d2