diff options
Diffstat (limited to 'numpy/_array_api/_array_object.py')
-rw-r--r-- | numpy/_array_api/_array_object.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/numpy/_array_api/_array_object.py b/numpy/_array_api/_array_object.py index 23f8ab333..32a7bc9a8 100644 --- a/numpy/_array_api/_array_object.py +++ b/numpy/_array_api/_array_object.py @@ -83,6 +83,9 @@ class ndarray: """ Performs the operation __bool__. """ + # Note: This is an error here. + if x._array.shape != (): + raise TypeError("bool is only allowed on arrays with shape ()") res = x._array.__bool__() return res @@ -111,6 +114,9 @@ class ndarray: """ Performs the operation __float__. """ + # Note: This is an error here. + if x._array.shape != (): + raise TypeError("bool is only allowed on arrays with shape ()") res = x._array.__float__() return res @@ -146,6 +152,9 @@ class ndarray: """ Performs the operation __int__. """ + # Note: This is an error here. + if x._array.shape != (): + raise TypeError("bool is only allowed on arrays with shape ()") res = x._array.__int__() return res |