From c2e10ec0cbd4c4ca56c61e10eb4df4ba11da0013 Mon Sep 17 00:00:00 2001 From: Nicolas Kruse Date: Fri, 19 Dec 2025 16:07:49 +0100 Subject: [PATCH] abs dunder function added for values --- src/copapy/_basic_types.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/copapy/_basic_types.py b/src/copapy/_basic_types.py index ec9b9ac..9b7455c 100644 --- a/src/copapy/_basic_types.py +++ b/src/copapy/_basic_types.py @@ -220,6 +220,9 @@ class value(Generic[TNum], Net): def __rfloordiv__(self, other: NumLike) -> Any: return add_op('floordiv', [other, self]) + def __abs__(self: TCPNum) -> TCPNum: + return cp.abs(self) # type: ignore + def __neg__(self: TCPNum) -> TCPNum: if self.dtype == 'float': return cast(TCPNum, add_op('sub', [value(0.0, volatile=False), self]))