<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/numpy/ticket/1477" rel="nofollow">http://projects.scipy.org/numpy/ticket/1477</a> on 2010-05-05 by trac user egonschiele, assigned to <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/pv/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/pv">@pv</a>.</em></p>
<p dir="auto">This might be just a question of precision. In the following code, A2 is a singular matrix. NumPy calculates it's inverse and prints out a non-zero determinant even though the matrix A2 is clearly singular:</p>
<p dir="auto">A = array([[.1,.01,.3],[.2,.99,.3],[.7,0,.4]])<br>
I = identity(3)</p>
<p dir="auto">A2 = A - I    # this should be singular<br>
print inv(A2) # prints out a singular matrix(!!)<br>
print det(A2) # prints -2.33146835171e-18 instead of 0</p>
<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/numpy/ticket/777" rel="nofollow">http://projects.scipy.org/numpy/ticket/777</a> on 2008-05-07 by trac user nick, assigned to unknown.</em></p>
<p dir="auto">When resize is called on a 2d array, if the value of the "column resize" is greater than the current column size, a wrapping of the values occurs. I noticed this while trying to resize a diagonal matrix. Example:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on
win32
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; from numpy import *
&gt;&gt;&gt; from numpy.lib import twodim_base
&gt;&gt;&gt; a = [1,2,3,4]
&gt;&gt;&gt; a_diag = twodim_base.diag(a)
&gt;&gt;&gt; print a_diag
[[1 0 0 0]
 [0 2 0 0]
 [0 0 3 0]
 [0 0 0 4]]
&gt;&gt;&gt; a_diag.resize((5,4))
&gt;&gt;&gt; print a_diag
[[1 0 0 0]
 [0 2 0 0]
 [0 0 3 0]
 [0 0 0 4]
 [0 0 0 0]]
&gt;&gt;&gt; a = [1,2,3,4]
&gt;&gt;&gt; a_diag = twodim_base.diag(a)
&gt;&gt;&gt; a_diag.resize((4,5))
&gt;&gt;&gt; print a_diag
[[1 0 0 0 0]
 [2 0 0 0 0]
 [3 0 0 0 0]
 [4 0 0 0 0]]
&gt;&gt;&gt;"><pre class="notranslate"><code class="notranslate">Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; from numpy import *
&gt;&gt;&gt; from numpy.lib import twodim_base
&gt;&gt;&gt; a = [1,2,3,4]
&gt;&gt;&gt; a_diag = twodim_base.diag(a)
&gt;&gt;&gt; print a_diag
[[1 0 0 0]
 [0 2 0 0]
 [0 0 3 0]
 [0 0 0 4]]
&gt;&gt;&gt; a_diag.resize((5,4))
&gt;&gt;&gt; print a_diag
[[1 0 0 0]
 [0 2 0 0]
 [0 0 3 0]
 [0 0 0 4]
 [0 0 0 0]]
&gt;&gt;&gt; a = [1,2,3,4]
&gt;&gt;&gt; a_diag = twodim_base.diag(a)
&gt;&gt;&gt; a_diag.resize((4,5))
&gt;&gt;&gt; print a_diag
[[1 0 0 0 0]
 [2 0 0 0 0]
 [3 0 0 0 0]
 [4 0 0 0 0]]
&gt;&gt;&gt;
</code></pre></div>
<p dir="auto">The documentation led me to believe that a column of 0's would be added (much like how a row of 0's was added when the number of rows was increased).</p>
<p dir="auto">Nick Loadholtes - <a href="mailto:nick@ironboundsoftware.com">nick@ironboundsoftware.com</a></p>