numba和numpy:'numpy.ndarray'对象没有属性'__code__'

时间:2014-03-03 02:40:00

标签: python numpy python-2.6 numba

我试过这段代码

from numba import jit
from numpy import arange
@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))

并获得了运行时异常:AttributeError: 'numpy.ndarray' object has no attribute '__code__'

我在numba的文档中找不到numpy的任何版本要求。目前我已经安装了numpy 1.7.1。我的python版本2.6.6

AttributeError 的原因是什么?

修改

一些堆栈跟踪信息;

 File "c:\pylib\numba\decorators.py", line 228, in _jit_decorator
    if func.__code__.co_argcount == 0 and argtys is None:
AttributeError: 'numpy.ndarray' object has no attribute '__code__'
Locals:
argtypes: 'None'
  argtys: 'None'
     env: 'NumbaEnvironment(numba)'
env_name: 'None'
    func: '[[0 1 2]\n [3 4 5]\n [6 7 8]]'
  kwargs: '{backend:ast}'
 restype: '<function sum2d at 0x1C89F5F0>'

0 个答案:

没有答案