Numpy array with cython

I am trying to port some python code to cython and I am encountering some minor issues.

Below you see a code snippet (simplified example) of the code.

cimport numpy as np cimport cython @cython.boundscheck(False) # turn of bounds-checking for entire function @cython.wraparound(False) @cython.nonecheck(False) def Interpolation(cells, int nmbcellsx): cdef np.ndarray[float,ndim=1] celle cdef int cellnonzero cdef int i,l for i in range(nmbcellsx): celle = cells[i].e cellnonzero = cells[i].nonzero for l in range(cellnonzero): celle[l] = celle[l] * celle[l] 

I don’t understand why the inner loop is not completely translated into C code (ie the last line, celle [l] = ...), see the output from cython -a feedback :

enter image description here

What am I missing here?

Thank you very much.

+6
source share
1 answer

Finally, I realized that a simple β€œreturn 0” at the very end of the function solves this problem. However, this behavior seems rather strange to me. Is this really a mistake?

+1
source

All Articles