mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-25 19:28:26 +08:00
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
Block a user