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

cdef-ing a memory view or array with a custom numpy dtype #2760

Open
NicolasHug opened this Issue Dec 16, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@NicolasHug
Copy link

NicolasHug commented Dec 16, 2018

I am trying to declare an array or a memory-view with a custom dtype, but I'm getting compilation errors:

cimport cython

import numpy as np
cimport numpy as np


MY_DTYPE = np.dtype([
    ('field_a', np.float32),
    ('field_b', np.float32),
])


def f():
    cdef MY_DTYPE.type [:] array

gives:

Error compiling Cython file:
------------------------------------------------------------
...
    ('field_b', np.float32),
])


def f():
    cdef MY_DTYPE.type [:] array
        ^
------------------------------------------------------------

sklearn/ensemble/blop.pyx:13:9: 'MY_DTYPE' is not a cimported module

Using cdef MY_DTYPE [:] array also fails with 'MY_DTYPE' is not a type identifier.

I've checked the docs, passed issues and the mailing list but could not find any example that didn't use numpy's built-in dtypes. This might be related to #2022?

Any help would be greatly appreciated!

@NicolasHug NicolasHug referenced a pull request that will close this issue Jan 23, 2019

Open

[DOC] Add doc for memory views with custom numpy dtype #2813

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment