-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Errors with various reduce
calls
#4504
Comments
Thanks for the report. The issue for the first two examples is that the |
Thanks for pointing me here! About the third example, should numpy and numba ufuncs in general have a |
No problem.
NumPy definitely has In [13]: x = np.arange(1, 6)
In [14]: np.multiply.reduce(x)
Out[14]: 120
In [15]: np.add.reduce(x)
Out[15]: 15 Numba from numba import njit, vectorize
import numpy as np
@vectorize(['int64(int64, int64)'])
def _my_add(a, b):
return np.add(a, b)
a = np.arange(1, 6)
print(_my_add.reduce(a)) However, in compiled code in general the |
Added a note mentioning that users shouldn't expect all ufunc features to work in compiled code. Based on comments from numba#4504 (comment).
After asking on gitter about whether my usage of
reduce
was supported, @stuartarchibald asked me to open this issue here.The basic issue is that I'd like to use
functools.reduce
, but was running into some errors. Here are three implementations I've tried and the errors they throw:Traceback (ValueError, invalid reduction function)
Traceback (KeyError)
Traceback (TypingError)
As pointed out on gitter, the first two errors seem to be caused by
numba
expecting the function passed toreduce
was defined locally.I think the third example has more to do with the extent of
ufunc
support innumba
, and might be a separate issue.I ran these examples with
numba v0.45.1
andnumpy v1.17.1
.The text was updated successfully, but these errors were encountered: