Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: ufunc shape (1, ) aliased operands #8273

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
mattharrigan opened this issue Nov 13, 2016 · 2 comments
Closed

BUG: ufunc shape (1, ) aliased operands #8273

mattharrigan opened this issue Nov 13, 2016 · 2 comments

Comments

@mattharrigan
Copy link
Contributor

mattharrigan commented Nov 13, 2016

>>> x = np.ones(10)
>>> np.add(x,x[:1],x)
array([ 2.,  3.,  3.,  3.,  3.,  3.,  3.,  3.,  3.,  3.])
>>> x = np.ones(10)
>>> np.add(x,x[4:5],x)
array([ 2.,  2.,  2.,  2.,  2.,  2.,  2.,  2.,  2.,  2.])

The first makes sense, but I expected the second to end with a string of 3's. Not totally sure if this is a bug or if aliased ufunc operands is documented as undefined behaviour somewhere.

The above was produced using the current master and ubuntu. On another windows machine with 1.10.4 I get even weirder:

>>> np.add(x,x[4:5],x)
array([ 2.,  2.,  2.,  2.,  2.,  2.,  2.,  2.,  2.,  3.])
@pv
Copy link
Member

pv commented Nov 13, 2016

duplicate of gh-1683

@pv pv closed this as completed Nov 13, 2016
@pv
Copy link
Member

pv commented Nov 13, 2016

The short answer is that ufunc operations on aliased input/output is undefined.

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

No branches or pull requests

2 participants