'numpy.ndarray' object is not callable error in python
<p>I was converting LU decomposition matlab code into python.</p>

<p>But while I was doing it I encountered with this error </p>

<blockquote>
  <p><code>'numpy.ndarray' object is not callable</code></p>
</blockquote>

<p>this error occurs when I tried to test my code. Here is my code and can anyone help with this problem?? I'm waiting for your help.</p>

<pre><code>import numpy as np

def LU(a):
    [m,m]=a.shape

    for k in range(0,m-1,1):
        a[k+1:m-1,k]=a[k+1:m-1,k]/a(k,k)
        a[k+1:m-1,k+1:m-1]=a[k+1:m-1,k+1:m-1]-a[k+1:m-1,k]*a[k,k+1:m-1]
    L=np.eye(m,m)+np.tril(a,-1)
    U=np.triu(a)
    return [L,U]

b=np.array([[1,0,0],[0,1,0],[0,0,1]])

LU(b)
</code></pre>

<p>The error is occurring because you have used the wrong kind of braces on the 4th line of your function.</p>

<pre><code>a[k+1:m-1,k]=a[k+1:m-1,k]/a(k,k)
</code></pre>

<p>should be corrected to </p>

<pre><code>a[k+1:m-1,k]=a[k+1:m-1,k]/a[k,k]
</code></pre>

<p>i.e. the <code>()</code> braces should be replaced by <code>[]</code>. The error is occurring because <code>[]</code> braces suggest an indexing operation, whereas <code>()</code> braces suggest a function call.</p>

python numpy callable