-
-
Notifications
You must be signed in to change notification settings - Fork 12.1k
Open
Description
EDITS:
- (Feature request: signal broadcasting is OK over core dimension #8811 (comment)): see ENH: Add frozen dimensions to gufunc signatures #5015 for allowing constants in the dimension, and worries about extending the C
ufuncAPI. - (Feature request: signal broadcasting is OK over core dimension #8811 (comment)): multiple signatures rather than creating a mini-language?
- (Feature request: signal broadcasting is OK over core dimension #8811 (comment)): need wishlist of things code should do before thinking of implementation.
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.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 forall_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 likematmul, but would seem to imply different functions for each signature.
Reactions are currently unavailable