2014-10-14 3 views
0

파이썬에서이 오류에 대한 몇 가지 질문을 읽었지만 코드에서 실수를 발견 할 수 없습니다. '파이썬에서 float 객체를 호출 할 수 없습니다.

def integrand3(x,v): 
    return (v[0]+v[1]*x+v[2]*x**2+v[3]*x**3+v[4]*x**4)*np.exp(x)*np.sin(np.pi()*x) 

def ProdInt1proy(v,inf=0,sup=1): 
    I,err = sp.quad(integrand3,inf,sup, args=v) 
    return I 

def Proyf(M,ProdInt): 
    return sum((ProdInt(M[i])*M[i]) for i in range(len(M))) 

Proyf(M,ProdInt1proy) 

Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/Users/Esgrid/anaconda/lib/python2.7/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 580, in runfile 
    execfile(filename, namespace) 
    File "/Users/Esgrid/Documents/CIMAT/Maestría Matemáticas Aplicadas/Semestre 1/Álgebra Lineal 1/Tarea 8 Álgebra.py", line 71, in <module> 
    print Proyf(M,ProdInt1proy) 
    File "/Users/Esgrid/Documents/CIMAT/Maestría Matemáticas Aplicadas/Semestre 1/Álgebra Lineal 1/Tarea 8 Álgebra.py", line 66, in Proyf 
    return sum((ProdInt(M[i])*M[i]) for i in range(len(M))) 
    File "/Users/Esgrid/Documents/CIMAT/Maestría Matemáticas Aplicadas/Semestre 1/Álgebra Lineal 1/Tarea 8 Álgebra.py", line 66, in <genexpr> 
    return sum((ProdInt(M[i])*M[i]) for i in range(len(M))) 
    File "/Users/Esgrid/Documents/CIMAT/Maestría Matemáticas Aplicadas/Semestre 1/Álgebra Lineal 1/Tarea 8 Álgebra.py", line 53, in ProdInt1proy 
    I,err = sp.quad(integrand3,inf,sup, args=v) 
    File "/Users/Esgrid/anaconda/lib/python2.7/site-packages/scipy/integrate/quadpack.py", line 281, in quad 
    retval = _quad(func,a,b,args,full_output,epsabs,epsrel,limit,points) 
    File "/Users/Esgrid/anaconda/lib/python2.7/site-packages/scipy/integrate/quadpack.py", line 345, in _quad 
    return _quadpack._qagse(func,a,b,args,full_output,epsabs,epsrel,limit) 
    File "/Users/Esgrid/Documents/CIMAT/Maestría Matemáticas Aplicadas/Semestre 1/Álgebra Lineal 1/Tarea 8 Álgebra.py", line 44, in integrand3 
    return (v[0]+v[1]*x+v[2]*x**2+v[3]*x**3+v[4]*x**4)*np.exp(x)*np.sin(np.pi()*x) 
TypeError: 'float' object is not callable 

ProdInt1Proy가 호출 될 때 발생

후 integrand3을 입력하고 오류가 발생합니다. 나는 어떤 도움을 주셔서 감사합니다.

+0

'np.pi()'는'np.pi'이어야합니다. – bernie

+0

룰 번호 1 : 추적을 포함한 정확한 오류 메시지를 보여줍니다. –

+0

규칙 번호 2 : 어딘가에 오류가있는 커다란 표현식이 있지만 어디에서 하나의 줄에 하나씩 별도의 표현식으로 구분하고 어느 것이 실패하고 있는지를 모를 때. – abarnert

답변

0

" 'float'object not callable"은 코드가 함수가 아닌 단순한 부동 소수점 숫자 인 객체에서 함수 호출을하는 것처럼 보입니다.

np.pi은 부동 소수점 상수이며 함수가 아닙니다. integrand3()에서 괄호를 빼십시오.

관련 문제