-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Add an axis argument to generalized ufuncs? #5197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think it's certainly functionality that we want to have. Details of the
|
I think it would be a great idea, if we can come up with a syntax that's both general enough and simple enough. The example of There are also plans to add optional dimensions to gufunc signatures, e.g. make But yes, it would be great if you could bring this up on the list. |
Possibly we should take advantage of the fact that gufunc axes have names On Fri, Oct 17, 2014 at 3:16 PM, Jaime notifications@github.com wrote:
Nathaniel J. Smith |
That would be very nice indeed. |
Posted to the list: http://mail.scipy.org/pipermail/numpy-discussion/2014-October/071455.html |
@ovillellas Thoughts? |
Implemented. |
I would like to write generalized ufuncs, using numba, to create fast functions such as
nanmean
(signature'(n)->()'
) orrolling_mean
(signature'(n),()->(n)'
) that take the axis along which to aggregate as a keyword argument, e.g.,nanmean(x, axis=0)
orrolling_mean(x, window=5, axis=0)
.Of course, I have the option of writing my own wrapper function to do something like
x.swapaxes(axis, -1)
before passing the array off to the gufunc. This is not so terrible.However, it occurs to me that this sort of dimension reordering might be handled more cleanly (and efficiently) within the gufunc machinery itself, somewhat analogously to
numpy.ufunc.reduce
, except theaxis
argument (if supplied) would need to be an integer or tuple with length equal to the number of core dimensions on the first gufunc argument.Thoughts?
The text was updated successfully, but these errors were encountered: