-
-
Notifications
You must be signed in to change notification settings - Fork 12k
Closed
Description
Here's a very simple __array_ufunc__, which is likely to be one of the first tests people try:
class foo(np.ndarray):
def __array_ufunc__(self, *args, **kwargs):
print(args, kwargs)
return super().__array_ufunc__(*args, **kwargs)Unfortunately, the error given is a little unhelpful:
>>> a = np.array(1).view(foo)
>>> a + a
(<ufunc 'add'>, '__call__', foo(1), foo(1)) {}
(<ufunc 'add'>, '__call__', foo(1), foo(1)) {}
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-13-24070be0e9db> in <module>()
----> 1 a + a
TypeError: operand type(s) do not implement __array_ufunc__(<ufunc 'add'>, '__call__', foo(1), foo(1)): 'foo', 'foo'
Some kind of hint that ndarray.__array_ufunc__ was not able to handle things either might be helpful.
mzechmeister
Metadata
Metadata
Assignees
Labels
No labels