python - 如何将参数作为元组传递给 odeint?

标签 python scipy

我想将 scipy 的 odeint 与一个函数一起使用

def func(y,t,a=123,b=456)

然后将其用作

odeint(func,y0,t)

如果我想使用 args 改变值 a 和 b

odeint(func,y0,t,args=(a=1,b=2))

它提示参数不是元组。 这可能是一个非常初级的问题, 如何将关键字参数作为元组传递?

odeint(func,y0,t,args=...?)

最佳答案

你只需要删除赋值来创建一个合法的元组:

odeint(func,y0,t,args=(123, 456))

There's another answer here with an example of calling odeint with arguments.

关于python - 如何将参数作为元组传递给 odeint?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34459843/

相关文章:

python - 从 scikit-learn 中的截断 SVD 中获取 U、Sigma、V* 矩阵

c++ - 使用 OpenCV 计算特征值、特征向量

python - scikit-learn MinMax 缩放器无法缩放

python - 如何从样本的最大值、最小值和平均值中找到分布函数

python - MongoEngine:限制来自 DBRef 的响应数量

python-docx中心表内容

python - Django 的 JSON 和 XML fixtures 导致 UnicodeEncodeError

Python NLTK 解析错误? 'str' 对象没有属性 'check_coverage'

python - 使用 OrdinalEncoder 转换分类值

image-processing - 空间卷积与频率卷积图像的逆滤波器