【问题标题】:Apparently missing scipy function显然缺少 scipy 功能
【发布时间】:2021-08-18 17:06:42
【问题描述】:

当我运行下面的脚本(取自 scipy 文档)时,我得到了 错误'属性错误:模块'scipy.integrate'没有属性'cumulative_trapezoid' 当我运行 dir (integrate) 时,函数列表中没有提及“cumulative_trapezoid”

from scipy import integrate
import matplotlib.pyplot as plt
x = np.linspace(-2, 2, num=20)
y = x
y_int = integrate.cumulative_trapezoid(y, x, initial=0)
plt.plot(x, y_int, 'ro', x, y[0] + 0.5 * x**2, 'b-')
plt.show()

【问题讨论】:

  • 您能否验证您使用的是什么版本的 scipy,并在此处添加?

标签: scipy integration


【解决方案1】:

cumulative_trapezoid 在 1.6 版中添加到 SciPy。您可以使用import scipy; print(scipy.__version__) 查看您拥有的版本。在旧版本的 SciPy 中,该函数称为 cumtrapz

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-14
    • 1970-01-01
    • 2018-09-17
    • 2022-01-21
    • 2021-06-15
    • 2017-06-05
    相关资源
    最近更新 更多