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
Vector @overload
not overwriting scalar one
#4324
Comments
Thanks for the report, I can reproduce, this is a bug. Interestingly this works: import numba
import scipy.special as sc
def zzz(x):
pass
@numba.extending.overload(zzz)
def gamma_scalar(a):
print("type of a", type(a))
print("testing float ty")
if isinstance(a, numba.types.Float):
print("Using scalar overload")
def scalar_impl(a):
print("In scalar overload")
return a ** 2
return scalar_impl
print("testing array ty")
if isinstance(a, numba.types.Array):
print("Using vector overload")
def foo(a):
print("In vector overload")
return a + 10
return foo
@numba.njit
def gamma(x):
return zzz(x)
import numpy as np
print(gamma(2.0))
print(gamma(np.array([2.0]))) which suggests it's something to do with binding the scipy module (probably not actually scipy related, just external module related). |
This is something to do with the array expression rewrite pass. |
ok, I think I've got it... what happens is this:
In one line... I think the fix might require making ufuncs care about the module the function came from (assuming that they don't now and that was the cause of the problem). |
latest released version of Numbamaster branch of Numba (most recent is visible in the change log (https://github.com/numba/numba/blob/master/CHANGE_LOG).to write one see http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports).
If I define a scalar overload for a function and then later define a vector overload, the vector overload appears to not be respected. A simple example is:
I would have expected to get
2.0
inOut[8]
.The text was updated successfully, but these errors were encountered: