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

Error when assigning a non-const memoryview to the copy of a const memoryview #2134

Closed
lesteve opened this issue Mar 8, 2018 · 1 comment
Labels
Milestone

Comments

@lesteve
Copy link

lesteve commented Mar 8, 2018

I have a const memoryview and I am trying to create a non-const memoryview by copying it. Naively I would expect it to be possible. Here is a snippet that reproduces the problem:

import numpy as np

cdef const double[:] ro = np.ones(3)
cdef double[:] rw = ro.copy()

The error I get:

Memoryview 'const double[::1]' not conformable to memoryview 'double[:]'.

If I read the error correctly it seems like ro.copy() type is still const.

A bit more context: I am trying out cython 0.28b1 and experimenting with const memoryviews in a scikit-learn context.

Side-comment: it is a slight variation of 6704d23 where instead of creating rw and then replacing the values by using rw[:] = ..., I am trying to do it in one line (which feels like the thing you would write in practice).

@lesteve
Copy link
Author

lesteve commented Mar 28, 2018

Nice, thanks a lot for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants