spi.odeint

7 views
Skip to first unread message

Sébastien Neukirch

unread,
Jun 30, 2021, 1:25:52 PM6/30/21
to Numba Public Discussion - Public
Hello,

I want to integrate an ODE with odeint and numba.

I am using numba with spi.odeint and I run into a numba-type problem.

I define the vector field:

# vector field 
@nba.jit(nopython=True) 
def vf(vec, t):  
    y,x = vec
    vecpoint = np.zeros(2)
    vecpoint[ 0] =  y * np.cos(x+y)   #  y' = y cos(x+y)    
    vecpoint[ 1] =  1.0   #  x' = 1    
    return vecpoint 

and then I want to define a small function that does the integration, with a given initial conditions:

@nba.jit(nopython=True)
def shoot(x0): 
    vecs = np.linspace(0., 30., 500)  # integration form t = 0 to 30
    vecx0 = np.zeros(2)
    vecx0[0] = x0
    v = spi.odeint(vf, vecx0, vecs)
    return v

Then, when I run:

shoot(1.0)

I get an Typing error, basically Numba says it does not know the type of v = spi.odeint(vf, vecx0, vecs)

How can I go around this ?

Many thanks !

sebastien

Valentin Haenel

unread,
Jun 30, 2021, 1:50:56 PM6/30/21
to numba...@continuum.io
Hi Sebastian,

first of all, this mailinglist has been largely retired and the Numba community is now using: https://numba.discourse.group/ - I would recommend to use that for any future questions.

As for your question, Numba only supports a limited subset of Python and NumPy -- which means that the 'spi'. package is not supported. You can read more about supported features here: https://numba.readthedocs.io/en/stable/reference/pysupported.html

Best wishes,

V-

--
You received this message because you are subscribed to the Google Groups "Numba Public Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numba-users...@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/numba-users/fee959f9-62fe-46c0-a8e2-fe21042f65ddn%40continuum.io.
Reply all
Reply to author
Forward
0 new messages