"AttributeError: 'list' object has no attribute 'ravel'"
10,984
Just do:
return np.array([xdot, ydot])
instead. This should work...
Comments
-
emma almost 2 years
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])
-
emma about 10 yearsstrange..i was pretty sure i've tried that before..anyway, it worked! thank you very much - i wish every problem could be solved in one line!
-
Saullo G. P. Castro about 10 years@klim I found out this was the problem based on your error message... since
ravel
is a method of thendarray
object, it was likely that returning the array instead of the list would solve the problem