相关疑难解决方法(0)

Numpy-> Cython转换:编译错误:无法将'npy_intp*'转换为Python对象

我有以下代码,适当地转换为cython:

from numpy import *

## returns winning players or [] if undecided. 
def score(board):
    scores = []
    checked = zeros(board.shape)
    for i in xrange(len(board)):
        for j in xrange(len(board)):
            if checked[i,j] == 0 and board[i,j] !=0:
                ... do stuf
Run Code Online (Sandbox Code Playgroud)

我尝试转换为cython:

import numpy as np
cimport numpy as np

@cython.boundscheck(False)
@cython.wraparound(False)
@cython.nonecheck(False)

## returns winning players or [] if undecided. 
def score(np.ndarray[int, ndim=2] board):
    scores = []
    cdef np.ndarray[int, ndim = 2 ] checked
    checked = np.zeros(board.shape)
    for i in xrange(len(board)): …
Run Code Online (Sandbox Code Playgroud)

python numpy cython scipy python-2.7

11
推荐指数
1
解决办法
6934
查看次数

标签 统计

cython ×1

numpy ×1

python ×1

python-2.7 ×1

scipy ×1