7

I'm trying to port some python code to cython and I'm encountering some minor problems.

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-most loop does not fully translate to C code (i.e. the last line, celle[l] = ...), see output from cython -a feedback:

enter image description here

What am I missing here?

Thanks a lot.

2
  • 1
    That image is a bit hard to read - Copy and paste of the relevant bit would be easier... Commented Jan 6, 2013 at 17:38
  • What c compiler do you have ? Is celle[l] *= celle[l] the same ? Commented Jan 7, 2013 at 17:24

1 Answer 1

1

I finally realized that a simple "return 0" at the very end of the function solves this problem. However, this behaviour seems quite strange to me. Is this actually a bug?

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.