<p dir="auto">Numpy 1.8.2 with python 2.7.6 has unconsistent behaviour when doing inplace division of arrays exceeding the buffer size.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import numpy as np
arr = np.random.rand(2, 5000)
arr_copy = arr.copy()
arr_copy = arr_copy / arr_copy[0]
arr /= arr[0]
print np.sum(arr != arr_copy), arr.size - np.sum(np.isclose(arr, arr_copy))"><pre class="notranslate"><code class="notranslate">import numpy as np
arr = np.random.rand(2, 5000)
arr_copy = arr.copy()
arr_copy = arr_copy / arr_copy[0]
arr /= arr[0]
print np.sum(arr != arr_copy), arr.size - np.sum(np.isclose(arr, arr_copy))
</code></pre></div>
<p dir="auto">Should print 0 for equal divisions.<br>
This can be circumvented by increasing the buffersize, nevertheless it should be emphasized, that this can happen.</p>
<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>