[SciPy-User] The ode function does not take *args ?
Ralf Gommers
ralf.gommers@gmail....
Sun Nov 11 13:28:18 CST 2012
On Sat, Nov 10, 2012 at 10:18 PM, The Helmbolds <helmrp@yahoo.com> wrote:
> Consider the following ode setup:
>
> t0 = 0
> # Order of variables changed from odeint's (w, t) to (t, w).
>
> def f(t, w, params): # Note -- no *args !!!
> A, D = params
> x, y = w
> return [-D * y, -A * x] # Returns a list.
>
> def jac(t, w, params): # Note -- no *args !!!
> A, D = params
> x, y = w
> return [ [0, -D], [-A, 0] ] # Returns a list of lists.
>
> from scipy.integrate import ode
> r = ode(f, jac)
> r.set_integrator('vode', method = 'adams', with_jacobian = True)
> r.set_initial_value(w0, t0)
> r.set_f_params(params) # Note -- no *args !!!
> r.set_jac_params(params) # Note -- no *args !!!
>
>
> tf = 10
> dt = 1
>
> while r.successful() and r.t < tf:
> r.integrate(r.t + dt)
> temp = [r.t, r.y]
> print 'temp = ', temp
>
> This produces essentially the same values as when using "odeint".
>
> My questions are as follows:
>
> Why the quirky change in the order of the variables?
>
Development history, no deep reason. Ideally this would match, but it can't
be changed anymore.
>
> I'm puzzled by the absence of *args or *params in "ode".
>
You give them with the set_f_params method, as shown in the docstring
example.
> Moreover, if I change any of these to the "*" form, then
> "ode" crashes with an error of the general form:
> "ValueError: need more than 0 values to unpack"
>
> What am I doing wrong?
>
Not sure because you don't show the code, but probably the set_f_params
method should fix this for you.
Ralf
>
> Running latest SciPy/NumPy with latest Python 2.7.x on Windows 7 64bit.
>
> Bob H
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20121111/ed295b2d/attachment.html
More information about the SciPy-User
mailing list