8000 BUG: ndarray.put disrespects flags.writeable = False · Issue #4465 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: ndarray.put disrespects flags.writeable = False #4465

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

Closed
immerrr opened this issue Mar 9, 2014 · 0 comments
Closed

BUG: ndarray.put disrespects flags.writeable = False #4465

immerrr opened this issue Mar 9, 2014 · 0 comments

Comments

@immerrr
Copy link
Contributor
immerrr commented Mar 9, 2014

It seems that ndarray.put disrespects writeable flag unlike other fancy indexing setters:

In [1]: np.__version__
Out[1]: '1.8.0'

In [2]: np.arange(10)
Out[2]: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])

In [3]: _2.flags.writeable = False

In [4]: _2[[1,2,3]] = 100
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-4-6b16d30888f3> in <module>()
----> 1 _2[[1,2,3]] = 100

ValueError: assignment destination is read-only

In [5]: _2.flat[[1,2,3]] = 100
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-5-ad5ff20cf609> in <module>()
----> 1 _2.flat[[1,2,3]] = 100

ValueError: underlying array is read-only

In [6]: _2.put([1,2,3], 100)

In [7]: _2
Out[7]: array([  0, 100, 100, 100,   4,   5,   6,   7,   8,   9])

At least 1.8.0 is affected, but given that PyArray_PutTo doesn't include PyArray_FailUnlessWriteable in master, I'd say master is affected too.

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

No branches or pull requests

2 participants
0