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
KeyError: <ufunc 'invert'> #8022
Comments
Hi @rishikeshkushwaha thank you for filing this issue. It's hard to understand the source of an error like this just from looking at the stack trace. Could you provide a runnable code sample that I can use to try reproduce this issue? Thanks. |
|
Running this code directly on main with Python 3.8 I see: >>> getitem(reflected list(reflected list(float64)<iv=None>)<iv=None>, Tuple(slice<a:b>, Literal[int](0)))
There are 22 candidate implementations:
- Of which 22 did not match due to:
Overload of function 'getitem': File: <numerous>: Line N/A.
With argument(s): '(reflected list(reflected list(float64)<iv=None>)<iv=None>, Tuple(slice<a:b>, int64))':
No match. However if I ensure from numba import jit, njit
import numpy as np
array_data = np.array([[ 3.47458169e+08, 4.77567825e+01, -1.22151398e+02,
4.76155090e+01, -1.22195724e+02, 2.47200000e+04,
2.66400000e+04],
[ 3.47458179e+08, 4.77567825e+01, -1.22151398e+02,
4.76155090e+01, -1.22195724e+02, 2.80200000e+04,
3.02400000e+04],
[ 3.47458209e+08, 4.76034737e+01, -1.22184975e+02,
4.77672043e+01, -1.22346100e+02, 6.11400000e+04,
6.57600000e+04],
[ 3.47458219e+08, 4.77677078e+01, -1.22346451e+02,
4.76015663e+01, -1.22187531e+02, 2.30400000e+04,
2.68200000e+04],
[ 3.47458229e+08, 4.77677078e+01, -1.22346451e+02,
4.76015663e+01, -1.22187531e+02, 2.46600000e+04,
2.84400000e+04]])
from math import radians, cos, sin, asin, sqrt
@jit( nopython=True)
def haversine(lon1, lat1, lon2, lat2):
lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])
dlon = lon2 - lon1
dlat = lat2 - lat1
a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2
c = 2 * asin(sqrt(a))
r = 6371
return c * r
@njit
def distance(i,j):
if i==j:
return 1000000.0
start = array_data[np.where(array_data[:,0]==i)][0][-1]
end = array_data[np.where(array_data[:,0]==j)][0][-2]
if i!=j and end > start + 20.0 :
lat1,long1 = array_data[np.where(array_data[:,0]==i)][0][3],array_data[np.where(array_data[:,0]==i)][0][4]
lat2,long2 = array_data[np.where(array_data[:,0]==j)][0][1],array_data[np.where(array_data[:,0]==j)][0][2]
return haversine(long1, lat1, long2, lat2)
else:
return 1000000.0
test = []
S = [i[0] for i in array_data]
for i in S[:5]:
for j in S[:5]:
test.append(distance(i,j))
print(test) @rishikeshkushwaha what Python version are you using? What version of Numba are you using? |
I think issue with previous version i.e. 0.53.x . I update and it fixed. Python 3.8. We can close this. |
Thanks for confirming @rishikeshkushwaha, closing. |
KeyError Traceback (most recent call last)
in
~\AppData\Roaming\Python\Python38\site-packages\numba\core\dispatcher.py in _compile_for_args(self, *args, **kws)
485 return lib.get_asm_str()
486
--> 487 return dict((sig, self.inspect_asm(sig)) for sig in self.signatures)
488
489 def inspect_types(self, file=None, signature=None,
~\AppData\Roaming\Python\Python38\site-packages\numba\core\dispatcher.py in _compile_for_args(self, *args, **kws)
418 e.patch_message(msg)
419
--> 420 error_rewrite(e, 'typing')
421 except errors.UnsupportedError as e:
422 # Something unsupported is present in the user code, add help info
~\AppData\Roaming\Python\Python38\site-packages\numba\core\dispatcher.py in compile(self, sig)
963 msg = "No parfors diagnostic available, is 'parallel=True' set?"
964 raise ValueError(msg)
--> 965 pfdiag.dump(level)
966 if signature is not None:
967 dump(signature)
~\AppData\Roaming\Python\Python38\site-packages\numba\core\dispatcher.py in compile(self, args, return_type)
123 def _customize_flags(self, flags):
124 return flags
--> 125
126
127 class _GeneratedFunctionCompiler(_FunctionCompiler):
~\AppData\Roaming\Python\Python38\site-packages\numba\core\dispatcher.py in _compile_cached(self, args, return_type)
137 # implementation function.
138 return serialize._get_function_globals_for_reduction(self.py_func)
--> 139
140 def _get_implementation(self, args, kws):
141 impl = self.py_func(*args, **kws)
~\AppData\Roaming\Python\Python38\site-packages\numba\core\dispatcher.py in _compile_core(self, args, return_type)
150 # We allow the implementation to omit default values, but
151 # if it mentions them, they should have the same value...
--> 152 if (pyparam.name != implparam.name or
153 pyparam.kind != implparam.kind or
154 (implparam.default is not implparam.empty and
~\AppData\Roaming\Python\Python38\site-packages\numba\core\compiler.py in compile_extra(typingctx, targetctx, func, args, return_type, flags, locals, library, pipeline_class)
~\AppData\Roaming\Python\Python38\site-packages\numba\core\compiler.py in init(self, typingctx, targetctx, library, args, return_type, flags, locals)
384 res = None
385 try:
--> 386 pm.run(self.state)
387 if self.state.cr is not None:
388 break
~\AppData\Roaming\Python\Python38\site-packages\numba\core\base.py in refresh(self)
273 from numba.cpython import (slicing, tupleobj, enumimpl, hashing, heapq,
274 iterators, numbers, rangeobj)
--> 275 from numba.core import optional
276 from numba.misc import gdb_hook, literal
277 from numba.np import linalg, polynomial, arraymath
~\AppData\Roaming\Python\Python38\site-packages\numba\core\cpu.py in load_additional_registries(self)
81 def target_data(self):
82 return self._internal_codegen.target_data
---> 83
84 def with_aot_codegen(self, name, **aot_options):
85 aot_codegen = codegen.AOTCPUCodegen(name, **aot_options)
~\AppData\Roaming\Python\Python38\site-packages\numba\np\npyimpl.py in
570
571
--> 572 _register_ufuncs()
573
574
~\AppData\Roaming\Python\Python38\site-packages\numba\np\npyimpl.py in _register_ufuncs()
549 for operator, ufunc_name in _op_map.items():
550 ufunc = getattr(np, ufunc_name)
--> 551 kernel = kernels[ufunc]
552 if ufunc.nin == 1:
553 register_unary_operator_kernel(operator, ufunc, kernel)
KeyError: <ufunc 'invert'>
getting this error when my input array is all float values.
try to increase performance using njit decorator.
The text was updated successfully, but these errors were encountered: