Skip to content

Instantly share code, notes, and snippets.

@cdeil
Created February 26, 2015 23:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdeil/472aae377314a4d58e84 to your computer and use it in GitHub Desktop.
Save cdeil/472aae377314a4d58e84 to your computer and use it in GitHub Desktop.
>>> from numba import jit
>>> from numpy import arange
>>>
>>> # jit decorator tells Numba to compile this function.
... # The argument types will be inferred by Numba when function is called.
... @jit
... def sum2d(arr):
... M, N = arr.shape
... result = 0.0
... for i in range(M):
... for j in range(N):
... result += arr[i,j]
... return result
...
>>> a = arange(9).reshape(3,3)
>>> print(sum2d(a))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numba/dispatcher.py", line 157, in _compile_for_args
return self.compile(sig)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numba/dispatcher.py", line 277, in compile
flags=flags, locals=self.locals)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numba/compiler.py", line 547, in compile_extra
return pipeline.compile_extra(func)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numba/compiler.py", line 293, in compile_extra
return self.compile_bytecode(bc, func_attr=self.func_attr)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numba/compiler.py", line 301, in compile_bytecode
return self._compile_bytecode()
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numba/compiler.py", line 534, in _compile_bytecode
return pm.run(self.status)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numba/compiler.py", line 191, in run
raise patched_exception
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numba/compiler.py", line 183, in run
res = stage()
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numba/compiler.py", line 367, in stage_objectmode_frontend
cres = self.frontend_looplift()
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numba/compiler.py", line 358, in frontend_looplift
func_attr=self.func_attr)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numba/compiler.py", line 556, in compile_bytecode
return pipeline.compile_bytecode(bc=bc, lifted=lifted, func_attr=func_attr)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numba/compiler.py", line 301, in compile_bytecode
return self._compile_bytecode()
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numba/compiler.py", line 534, in _compile_bytecode
return pm.run(self.status)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numba/compiler.py", line 191, in run
raise patched_exception
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numba/compiler.py", line 183, in run
res = stage()
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numba/compiler.py", line 469, in stage_objectmode_backend
res = self._backend(lowerfn, objectmode=True)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numba/compiler.py", line 447, in _backend
lowered = lowerfn()
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numba/compiler.py", line 425, in backend_object_mode
self.flags)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numba/compiler.py", line 705, in py_lowering_stage
lower.lower()
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numba/lowering.py", line 238, in lower
self.pre_lower()
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numba/objmode.py", line 53, in pre_lower
"Numba internal error: object mode function called "
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numba/pythonapi.py", line 121, in err_set_string
msg = self.context.insert_const_string(self.module, msg)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numba/targets/base.py", line 250, in insert_const_string
for gv in mod.global_variables:
AttributeError: Failed at object (object mode frontend)
Failed at object (object mode backend)
'Module' object has no attribute 'global_variables'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment