[Numpy-discussion] Re: Is a Python function a gufunc if it broadcasts its arguments appropriately?

2025-01-02 Thread Jim Pivarski via NumPy-Discussion
In preparing my email, I was looking for a way to identify a ufunc, other than `isinstance`, since `np.vectorize` and `nb.vectorize` make objects that behave like ufuncs (even obeying NEP 13 semantics, checking for `__array_ufunc__`), but they don't inherit from the `np.ufunc` type. I was thinking

[Numpy-discussion] Re: Is a Python function a gufunc if it broadcasts its arguments appropriately?

2025-01-02 Thread Sebastian Berg
Stack is not a generalized ufunc. It may behave similar to one in many ways, but implementation wise has nothing to do with ufuncs. Also ufuncs do not support an arbitrary number of operands. `vectorize` can indeed mimic generalized ufuncs, but (unfortunately) doesn't create them as such currentl