From 94853722772f50f1c9428fa3ab8354561e415691 Mon Sep 17 00:00:00 2001 From: Yann Sionneau Date: Fri, 20 Feb 2015 17:37:30 +0100 Subject: [PATCH] units: add support for abs() on Quantity --- artiq/language/units.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/artiq/language/units.py b/artiq/language/units.py index cb912014e..23dc96f6f 100644 --- a/artiq/language/units.py +++ b/artiq/language/units.py @@ -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)