-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Invalid result from Reduction Iteration in given example #10410
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
Comments
Can you link to where the example comes from? (edit: updated top post with working link) |
It is in the documentation, under the Iterating Over Arrays section - Reduction Iteration example for summation of all elements in an array |
Looks like it fails for the same reason that the following does: x = np.lib.stride_tricks.as_strided(0, shape=(4,), strides=(0,))
x += np.arange(len(x))
x
# array([3, 3, 3, 3]), expecting array([6, 6, 6, 6]) |
Strangely, using |
`np.add(x, y, out=z)` should be the same as `np.add(x.copy(), y.copy(),
out=z)`, otherwise it's a bug.
|
I don't think there are exceptions from the above rule, at least I don't
recall adding special cases for 0-stride arrays.
|
Thanks for chiming in Looking at these lines from @pv's PR, it seems that this change was deliberate, |
Yeah, I somewhat guess it is a change in behaviour that was in some sense anticipated. Is this actually creating problems for you? The nditer API, is a bit too close to the C-API for its own good/nice usage sometimes.... |
Closing, this was never a bug/regression, but a deliberate change in our API to protect the vast majority of users (of course some like me in my early days had code that did use this). |
Uh oh!
There was an error while loading. Please reload this page.
The example for Reduction Iteration is producing the wrong result.
produces result:
which is not accurate
I am using latest anaconda, Windows 7, 64bit, python 2.7, numpy 1.13.1, jupyter 1.0.0
The text was updated successfully, but these errors were encountered: