[SciPy-user] ode/programming question
Mon Apr 30 15:27:40 CDT 2007
> -----Original Message-----
> From: firstname.lastname@example.org
> Behalf Of Anne Archibald
> Sent: Monday, April 30, 2007 12:48 PM
> To: SciPy Users List
> Subject: Re: [SciPy-user] ode/programming question
> On 30/04/07, Trevis Crane <email@example.com> wrote:
> > When using one of the ODE solvers, you can pass it a list of
> > These arguments are used in the function that defines the system of
> > equations that you're solving. What if I want to modify an argument
> > iteration and re-pass this modified argument to the helper function
> > next iteration? In Matlab (what I'm most familiar with), this is
easy to do,
> > using "nested" functions, because they share the same
scope/namespace as the
> > function they're nested in. This is not the case in Python,
however, so I'm
> > curious what the best way of doing this would be. I assume I define
> > global variable, but I'm wondering if there's another, perhaps
> > of doing it.
> I would use a class that implements the __callable__ method if I
> wanted to store some state. But be warned that the ODE solver is going
> to assume that your function always returns the same value for the
> same inputs, and it's unlikely to call the function in t order.
I found reference to a __call__ method, but not the __callable__ method.
Can you point me to a description of it?
In reference to you comment about the ODE not likely calling the
function in t order -- you're saying that the ODE solver doesn't
necessarily progress in a monotonic fashion from t = t_0 to t = t_final?
Hmm. I hadn't thought of that.
> Incidentally, I've never understood why python has all those "args"
> arguments. It makes the code and signature for functions with function
> arguments complicated and confusing, and it's not usually enough: for
> example, if you want to use the minimization functions to maximize,
> you either have to write a function apurpose or you have to feed it a
> lambda; in either case you can easily curry the function arbitrarily.
> So I never ever use the "args" arguments. Why are they there?
> SciPy-user mailing list
More information about the SciPy-user