forked from M-Labs/artiq
units: add support for abs() on Quantity
This commit is contained in:
parent
651ed71b79
commit
9485372277
|
@ -156,6 +156,9 @@ class Quantity:
|
||||||
def __pos__(self):
|
def __pos__(self):
|
||||||
return Quantity(self.amount.__pos__(), self.unit)
|
return Quantity(self.amount.__pos__(), self.unit)
|
||||||
|
|
||||||
|
def __abs__(self):
|
||||||
|
return Quantity(abs(self.amount), self.unit)
|
||||||
|
|
||||||
# add/sub
|
# add/sub
|
||||||
def __add__(self, other):
|
def __add__(self, other):
|
||||||
return self._binop(other, "__add__", addsub_dimension)
|
return self._binop(other, "__add__", addsub_dimension)
|
||||||
|
|
Loading…
Reference in New Issue