scipy - 显然缺少 scipy 功能
问题描述
当我运行下面的脚本(取自 scipy 文档)时,我收到错误 'Attribute Error: module 'scipy.integrate' has no attribute 'cumulative_trapezoid' 当我运行 dir (integrate) 时,列表中没有提及函数“累积梯形”
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()
解决方案
cumulative_trapezoid
was added to SciPy in version 1.6. You can check which version you have with import scipy; print(scipy.__version__)
. In older versions of SciPy, the function is called cumtrapz
.
推荐阅读
- javascript - 如何在 RichEmbed/MessageEmberd 中发送 gif
- php - Wordpress cookie 只能从一个页面获得,即使它是为整个域设置的
- python - ERROR:process_reader_win.cc(123)] NtOpenThread: {Access Denied} 尝试使用 Selenium 在 Python 上运行图像下载器
- trust - 如何在两个 freeIPA 实例之间设置跨领域信任
- python - Why GUI should use call_soon_threadsafe() when talking to asyncio loop
- javascript - 如何正确调用从第三方脚本导入的 js 模块
- html - 如何在烧瓶 wtf 中使用自定义标签?
- google-cloud-platform - 在 gitops 原理中使用 Gitlab、Terraform、Flux 和 GKE 的最佳方式
- java - 无法在多人游戏中注册自定义剑
- json - 通过 FileMaker Pro 使用 JSON cURL 更新补丁 Microsoft Graph API Planner 任务详细信息产生错误 204