From deaf0bf6fc819c9c7b4dcffe0d4aee43bdc33bae Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Thu, 22 Jul 2021 18:19:59 -0600 Subject: Fix the array API __abs__() to restrict to numeric dtypes --- numpy/_array_api/_array_object.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'numpy/_array_api/_array_object.py') diff --git a/numpy/_array_api/_array_object.py b/numpy/_array_api/_array_object.py index 98e2f78f9..cd16f49ee 100644 --- a/numpy/_array_api/_array_object.py +++ b/numpy/_array_api/_array_object.py @@ -317,6 +317,8 @@ class Array: """ Performs the operation __abs__. """ + if self.dtype not in _numeric_dtypes: + raise TypeError('Only numeric dtypes are allowed in __abs__') res = self._array.__abs__() return self.__class__._new(res) -- cgit v1.2.1