Closed
Description
Take the following example:
import numpy as np
class MyArr(np.ndarray):
def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
func = getattr(ufunc, method)
inp = [i.view(np.ndarray) for i in inputs]
return func(*inp, **kwargs)
data = np.array([[1, 2, 3], [1, 2, 3]])
arr = data.view(MyArr)
print(data.max())
print(arr.max())
On numpy 1.13rc1 this prints:
3
[1 2 3]
For the call to arr.max()
numpy calls __array_ufunc__
, but there doesn't seem to be a way to tell from inside __array_ufunc__
that we should be reducing across the whole array and not just the first dimension. I think this would work properly if numpy were calling __array_ufunc__
with axis=None
.
Ping @mhvk