Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@cython.locals(arr=np.ndarray[np.int_t, ndim=1]) not supported #3129

Open
paugier opened this issue Sep 4, 2019 · 0 comments

Comments

@paugier
Copy link

commented Sep 4, 2019

It seems that one can't declare np.ndarray in cython.locals in .pxd files. It works with memoryviews but not with np.ndarray. However, there are cases where we need np.ndarray.

In notsupported.py

import numpy as np

def func():
    arr = np.ones(2)
    return arr

In notsupported.pxd

import cython

import numpy as np
cimport numpy as np

@cython.locals(arr=np.ndarray[np.int_t, ndim=1])
cpdef func()

Error log:

Error compiling Cython file:
------------------------------------------------------------
...
import cython

import numpy as np
cimport numpy as np

@cython.locals(arr=np.ndarray[np.int_t, ndim=1])
                                           ^
------------------------------------------------------------

notsupported.pxd:6:44: Expected ']', found '='

Couldn't it be supported? What is the alternative?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.