2
0
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:
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): 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)