1

I was working on a cournot problem, but was getting this error:

TypeError: 'numpy.ndarray' object is not callable

Can anyone help me locate the error I am getting?

8
  • Could you post the entire error traceback? Commented Apr 29, 2017 at 13:23
  • '---> 16 c1= broyden1(resid(c,p_node,alpha,eta,phi), c) 17 phi1= np.polynomial.chebyshev.chebval(p_node,c1) 18 q1= phi1*c1 \scipy\optimize\nonlin.py in nonlin_solve(F, x0, jacobian,..) 274 275 dx = np.inf --> 276 Fx = func(x) 277 Fx_norm = norm(Fx) C:\Users\Gagan\Anaconda3\lib\site-packages\scipy\optimize\nonlin.py in <lambda>(z) 270 271 x0 = _as_inexact(x0) --> 272 func = lambda z: _as_inexact(F(_array_like(z, x0))).flatten() 273 x = x0.flatten() 274 TypeError: 'numpy.ndarray' object is not callable' Commented Apr 29, 2017 at 14:13
  • @ElinaGilbert formating tip: 4 spaces for code, 8 spaces for indented code. Commented Apr 29, 2017 at 14:26
  • What arguments does broyden1 take? Function? Initial value, args tuple? Commented Apr 29, 2017 at 15:01
  • @hpaulj 'broyden1' takes function and an initial guess value and returns the root finding solution. Here my initial guess is c=chebfit... Commented Apr 29, 2017 at 15:33

1 Answer 1

1

Your function resid returns an numpy-array at call-time.

Your need to give broyden a function, but gave it a called function, so it's not a function anymore, but was already evaluated to some array. This results in broyden1 to call the resulting numpy-array.

This is not equal:

c1= broyden1(resid(c,p_node,alpha,eta,phi), c)
c1= broyden1(resid, c)

I'm ignoring possible consequences here.

Sign up to request clarification or add additional context in comments.

1 Comment

can you please suggest an alternative code to solve the same problem. Actually my motive is to find a coefficient c which makes mr-mc=0. Also, I have already tried c1= broyden1(resid, c) but it gives non convergent solution with error

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.