Skip to content

Instantly share code, notes, and snippets.

@bayerj
Created January 11, 2013 19:45
Show Gist options
  • Select an option

  • Save bayerj/4513419 to your computer and use it in GitHub Desktop.

Select an option

Save bayerj/4513419 to your computer and use it in GitHub Desktop.
This is unexpected behaviour when compiling a moving average function with numba. Not compiling it and using python+numpy works fine.
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-4-f143d352e435> in <module>()
----> 1 filtered = mean_filter(X, 10)
/Users/bayerj/anaconda/lib/python2.7/site-packages/numba/decorators.pyc in __call__(self, *args, **kwargs)
162 raise error.NumbaError("Expected %d arguments, got %d" % (
163 nargs, len(args)))
--> 164 return self.wrapper(self, *args, **kwargs)
165
166 def invoke_compiled(self, compiled_numba_func, *args, **kwargs):
/Users/bayerj/anaconda/lib/python2.7/site-packages/numba/decorators.pyc in wrapper(numba_func, *args, **kwargs)
187 **translator_kwargs)
188 compiled_numba_func = dec(f)
--> 189 return numba_func.invoke_compiled(compiled_numba_func, *args, **kwargs)
190
191 f.live_objects = []
/Users/bayerj/anaconda/lib/python2.7/site-packages/numba/decorators.pyc in invoke_compiled(self, compiled_numba_func, *args, **kwargs)
165
166 def invoke_compiled(self, compiled_numba_func, *args, **kwargs):
--> 167 return compiled_numba_func(*args, **kwargs)
168
169 def jit_extension_class(py_class, translator_kwargs):
/Users/bayerj/anaconda/lib/python2.7/site-packages/numba/decorators.pyc in __call__(self, *args, **kwargs)
153 def __call__(self, *args, **kwargs):
154 if self.ctypes_func:
--> 155 return self.invoke_compiled(self.ctypes_func, *args, **kwargs)
156 else:
157 if kwargs:
/Users/bayerj/anaconda/lib/python2.7/site-packages/numba/decorators.pyc in invoke_compiled(self, compiled_numba_func, *args, **kwargs)
165
166 def invoke_compiled(self, compiled_numba_func, *args, **kwargs):
--> 167 return compiled_numba_func(*args, **kwargs)
168
169 def jit_extension_class(py_class, translator_kwargs):
ValueError: could not broadcast input array from shape (0) into shape (2)
(100, 2)
/Users/bayerj/anaconda/lib/python2.7/site-packages/numba/decorators.py:167: RuntimeWarning: tp_compare didn't return -1 or -2 for exception
return compiled_numba_func(*args, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment