<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; x = np.ones(10)
&gt;&gt;&gt; np.add(x,x[:1],x)
array([ 2.,  3.,  3.,  3.,  3.,  3.,  3.,  3.,  3.,  3.])
&gt;&gt;&gt; x = np.ones(10)
&gt;&gt;&gt; np.add(x,x[4:5],x)
array([ 2.,  2.,  2.,  2.,  2.,  2.,  2.,  2.,  2.,  2.])"><pre class="notranslate"><code class="notranslate">&gt;&gt;&gt; x = np.ones(10)
&gt;&gt;&gt; np.add(x,x[:1],x)
array([ 2.,  3.,  3.,  3.,  3.,  3.,  3.,  3.,  3.,  3.])
&gt;&gt;&gt; x = np.ones(10)
&gt;&gt;&gt; np.add(x,x[4:5],x)
array([ 2.,  2.,  2.,  2.,  2.,  2.,  2.,  2.,  2.,  2.])
</code></pre></div>
<p dir="auto">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.</p>
<p dir="auto">The above was produced using the current master and ubuntu.  On another windows machine with 1.10.4 I get even weirder:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; np.add(x,x[4:5],x)
array([ 2.,  2.,  2.,  2.,  2.,  2.,  2.,  2.,  2.,  3.])"><pre class="notranslate"><code class="notranslate">&gt;&gt;&gt; np.add(x,x[4:5],x)
array([ 2.,  2.,  2.,  2.,  2.,  2.,  2.,  2.,  2.,  3.])
</code></pre></div>
<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/numpy/ticket/1085" rel="nofollow">http://projects.scipy.org/numpy/ticket/1085</a> on 2009-04-15 by trac user tillmann, assigned to <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/charris/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/charris">@charris</a>.</em></p>
<blockquote>
<blockquote>
<blockquote>
<p dir="auto">import numpy as np<br>
x=np.array([[1,2],[3,4]])<br>
print x<br>
[[1 2]<br>
[3 4]]<br>
x+=x.T<br>
print x<br>
[[2 5]<br>
[8 8]]</p>
</blockquote>
</blockquote>
</blockquote>
<p dir="auto">when writing code on such a high level of abstraction this behavior is not expected and imho wrong. At least a warning should be issued or better the in place operations should fall back to creating copies if the results are not correct otherwise.</p>