You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before numpy 1.10, there was automatic broadcasting over core dimensions in gufunc. While this is not necessarily good for many things (e.g., np.inner1d in the example in the documentation), it is for others, such as the all_equal implementation in #8528. It would be nice if the signature allowed one to make this distinction.
Wishlist beyond broadcasting
Multiple related signatures, such as for matmul: (i,k),(k,j)->(i,j), (i,j),(i)=(i,j),(i,1)->(i,j), (i),(i,j)=(1,i),(i,j)->(i,j)
Possibly having the output signature be calculated from the input dimensions (min(i,j))
Possible implementations
Noting that signature has to be a single char to remain compatible with the API:
Adjust the interpretation of dimensions, e.g., (i|1), (i|1)->() or (i?), (i?)->() (Add an axis argument to generalized ufuncs? #5197) might convey what is needed for all_equal (easy to do with setting relevant strides to 0)
Allow multiple signatures; e.g., (i),(i)->(); (i),()->(); (),(i)->(); (),()->(). This would likely make the most sense for things like matmul, but would seem to imply different functions for each signature.
EDITS:
ufuncAPI.Rationale
Before numpy 1.10, there was automatic broadcasting over core dimensions in
gufunc. While this is not necessarily good for many things (e.g.,np.inner1din the example in the documentation), it is for others, such as theall_equalimplementation in #8528. It would be nice if the signature allowed one to make this distinction.Wishlist beyond broadcasting
(i,k),(k,j)->(i,j),(i,j),(i)=(i,j),(i,1)->(i,j),(i),(i,j)=(1,i),(i,j)->(i,j)min(i,j))Possible implementations
Noting that
signaturehas to be a singlecharto remain compatible with the API:(i|1), (i|1)->()or(i?), (i?)->()(Add an axis argument to generalized ufuncs? #5197) might convey what is needed forall_equal(easy to do with setting relevant strides to 0)(i),(i)->(); (i),()->(); (),(i)->(); (),()->(). This would likely make the most sense for things likematmul, but would seem to imply different functions for each signature.