I have a function that returns an array:
def fun(x,a):
return [a*x,a*x**2]
and I want to integrate it (using scipy quad):
def integrate(a):
return quad(fun[0],0,1,args=a)
print integrate(1)
This gives TypeError: 'function' object is not subscriptable.
What's the right, pythonic way to do this?
ax?fun[0]is trying to subscript the function. Did you want to subscript the results of the function? In that case the syntax isfun(param1, param2)[0]funis your funciton, notfun[0]. Also, do not call the second function "int" since that clobbers the standard python "int" type in your namespace.