Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass arguments as tuple to odeint?

Tags:

python

scipy

I wanted to use odeint of scipy with a function

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

then use it as

odeint(func,y0,t)

If I want to change the values a and b using args

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

It complains that arguments are not tuple. It may be a very elementary question, how can I pass keyword arguments as a tuple?

odeint(func,y0,t,args=...?)
like image 392
user2775514 Avatar asked Oct 31 '22 12:10

user2775514


1 Answers

You just need to remove the assignments to make a legit tuple:

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

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

like image 148
pneumatics Avatar answered Nov 15 '22 05:11

pneumatics