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
np.add with flat/reshape out argument #7244
Comments
The problem is entirely with Do you have an actual use case here, or is it just that you're frustrated that the book is wrong? Are you aware that there's a second edition of the book available? |
I got confused about when
that these two should be identical. But of course the first one returns a copy during I'm very sorry to have bothered you. |
Sorry if i sounded curt above -- just writing quickly from my phone :-). The rules on returning views versus copies are definitely not obvious and easy to get confused by! Thinking about it actually wouldn't be hard to issue a warning in the case where |
No problem, I was just emberassed because I missed that it created a temporary copy. :-) I'll reopen the issue because such a Warning would be very helpful. |
Closing for now, there might be a point in looking it again, but the past PR didn't work out, so it is probably more complicated (and does not seem very pressing). |
There is an issue on SO with the
out
argument ofnp.add
and I tried almost everything and it's impossible (?) to get theout
argument working if it's a view of another array. At least I couldn't work out how it could be done. Even if the behaviour is intended there should be a Warning/Error. Becausenp.add(b, b, a[1:3, 0:3].flat)
(doesn't work at all becauseout
is an iterator not an array and aTypeError
is raised.) should be equivalent toa[1:3, 0:3].flat = np.add(b, b)
(which works!).I'm not very familiar with
numpy
internals so I can only guess what's causing this.The text was updated successfully, but these errors were encountered: