2014-06-10 1 views
0

전체 프로그램이 옳습니다 (여러 단계에서 확인했습니다). 그러나이 모듈에서 강조 표시된 행은 다음과 같은 오류를 반환합니다.scipy.optimize.newton이 제공하는 TypeError : 터플 ("int"가 아님)을 튜플에 연결할 수 있습니다.

TypeError: can only concatenate tuple (not "int") to tuple 

왜 이런 일이 발생하는지 알 수 없습니다. funcPsat은 float 값을 반환합니다. 유용한 조언을 부탁드립니다.

import scipy.optimize.newton as newton 

def Psat(self, T): 
    pop= self.getPborder(T) 
    boolean=int(pop[0]) 
    P1=pop[1] 
    P2=pop[2] 
    if boolean: 
     Pmin = min([P1, P2]) 
     Pmax = max([P1, P2]) 
     if Pmin > 0.0: 
      Pguess = 0.5*(Pmin+Pmax) 
     else: 
      Pguess=0.5*Pmax 
     solution = newton(self.funcPsat, Pguess, args=(T)) #error in this line 
     return solution 
    else: 
     return None 
+0

당신이 전체 오류 추적을 제공 할 수 있을까요? 'T' 란 무엇입니까? – jonrsharpe

답변

3

나는 문제가 문서

args :tuple, optional

Extra arguments to be used in the function call.

args 인수가 tuple 있어야한다는 것입니다 생각합니다.

괄호를 넣는 것만으로는되지 않습니다. 튜플에 대한 구문은 쉼표입니다. 예를 들면 :

>>> T = 0 
>>> type((T)) 
<type 'int'> 
>>> type((T,)) 
<type 'tuple'> 

시도 :

solution = newton(self.funcPsat, Pguess, args=(T,)) 
               #^note comma 
+0

존 감사합니다! 그것은 작동합니다! 예! –

관련 문제