units: add support for abs() on Quantity

This commit is contained in:
Yann Sionneau 2015-02-20 17:37:30 +01:00 committed by Sebastien Bourdeauducq
parent 651ed71b79
commit 9485372277

View File

@ -156,6 +156,9 @@ class Quantity:
def __pos__(self):
return Quantity(self.amount.__pos__(), self.unit)
def __abs__(self):
return Quantity(abs(self.amount), self.unit)
# add/sub
def __add__(self, other):
return self._binop(other, "__add__", addsub_dimension)