Open sdx23 opened 7 years ago
Thanks, I think that is a useful suggestion, so that we can provide an interface as close to odeint
as possible.
I'll implement this when I can get some time.
In the meantime you can get the same effect by passing a python closure in place of f
or G
.
Hey there! Has any progress been made on this addition, would really appreciate it :)
In the current version, it is easy to achieve the same goal by using a function closure, so it is not a very high priority. A pull request adding this functionality would be welcome, of course.
@mattja can you provide an example using the function closure?
import numpy as np
import sdeint
def close(func, *args):
def newfunc(x, t):
return func(x, t, *args)
return newfunc
tspan = np.linspace(0.0, 5.0, 5001)
x0 = 0.1
def f(x, t, a, b):
return -(a + x*b**2)*(1 - x**2)
def g(x, t, a, b):
return b*(1 - x**2)
args = (1.0, 0.8)
result = sdeint.itoint(close(f, *args), close(g, *args), x0, tspan)
odeint
hasargs=[]
for this purpose. In case of sdeint we'd possibly need two separate parameters,argsf
andargsG
.