aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2017-12-22 11:08:40 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2017-12-22 11:08:40 +0100
commitb21aa9f9493c55eb15b1b48e00eef05bb528e064 (patch)
tree54a997d27823baed20f10b974688d0e832d8499f /src
parent867852503157299b67fe05645aea11b9da0f2a84 (diff)
downloadee-python-b21aa9f9493c55eb15b1b48e00eef05bb528e064.tar.gz
ee-python-b21aa9f9493c55eb15b1b48e00eef05bb528e064.tar.bz2
ee-python-b21aa9f9493c55eb15b1b48e00eef05bb528e064.tar.xz
ee-python-b21aa9f9493c55eb15b1b48e00eef05bb528e064.zip
o Allow __lt__ to work when only one unit is set.
Diffstat (limited to 'src')
-rw-r--r--src/ee/__init__.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/ee/__init__.py b/src/ee/__init__.py
index 7f228f8..aa2c109 100644
--- a/src/ee/__init__.py
+++ b/src/ee/__init__.py
@@ -86,7 +86,17 @@ class EeVal(object):
return math.isclose(self.__float__(), other.__float__()) and self._unit == other._unit
def __lt__(self, other):
- return ((self.__float__(), self._unit) < (other.__float__(), other._unit))
+# return ((self.__float__(), self._unit) < (other.__float__(), other._unit))
+
+ x = self.__float__() < other.__float__()
+ if x != 0:
+ return x
+ if self._unit is None and other._unit is None:
+ return 0
+ if self._unit is not None and other._unit is not None:
+ return self._unit < other._unit
+
+ return 1 if self.unit is not None else -1
def __str__(self):
return eng_str(self.__float__(), self._unit)