" AttributeError:“列表"对象没有属性"ravel"" [英] "AttributeError: 'list' object has no attribute 'ravel'"
本文介绍了" AttributeError:“列表"对象没有属性"ravel""的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个微分方程组,需要计算雅可比行列式.下面的代码引发 AttributeError:'list'对象没有属性'ravel'
.我想念什么?
I have a system of differential equations and need to calculate the Jacobian. The code below throws AttributeError: 'list' object has no attribute 'ravel'
. What am I missing?
import numpy as np
import numdifftools as ndt
def rhs(z, t=0):
x,y = z
xdot = (x/5 + y)*(-x**2+1)
ydot = -x*(-y**2+1)
return [xdot, ydot]
Jfun = ndt.Jacobian(rhs)
Jfun([1,1])
推荐答案
只需:
return np.array([xdot, ydot])
相反.这应该起作用...
instead. This should work...
这篇关于" AttributeError:“列表"对象没有属性"ravel""的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文