Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"AttributeError: 'list' object has no attribute 'ravel'"

Tags:

python

list

numpy

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])
like image 297
emma Avatar asked Mar 11 '14 14:03

emma


1 Answers

Just do:

return np.array([xdot, ydot])

instead. This should work...

like image 136
Saullo G. P. Castro Avatar answered Oct 21 '22 13:10

Saullo G. P. Castro