TypeError:“模块”对象无法在scipy上调用,优化模块

时间:2019-07-19 19:41:20

标签: python python-import scipy-optimize

我正在使用scipy的scipy.optimize.brentq查找函数的零,但是每当我调用该函数时,我都会遇到TypeError:

zero1 = ot.brentq(sy.evalf(bMaxPrime), -2, 0)

TypeError: 'module' object is not callable

来自此函数:

def derivativeBMax(s, a, b):
B0 = 1
x = sy.symbols('x', real=True)
num1 = B0 * sy.exp(-(s**2 + x ** 2)/ b**2)
num2 = sy.sin(sy.atan(sy.sqrt(s ** 2 + x ** 2) / s)) 
num3 = sy.sin((math.pi/2) * (1 - sy.exp(-(s**2 + x ** 2)/ a**2)))
bMax = num1 * num2 * num3
bMaxPrime = sy.diff(bMax, x)
print(str(bMaxPrime))
zero1 = ot.brentq(sy.evalf(bMaxPrime), -2, 0)
zero2 = ot.brentq(sy.evalf(bMaxPrime), 0, 2)
return zero1, zero2 

我已经检查了我的进口货

import math
from scipy import special as sp
from scipy import optimize as ot
import matplotlib.pyplot as plt2
import matplotlib.lines as mlines
import sympy as sy

但是我不确定为什么将ot导入scipy.optimize是错误的。

0 个答案:

没有答案