[SciPy-user] ode/programming question

Trevis Crane t_crane@mrl.uiuc....
Mon Apr 30 15:27:40 CDT 2007



> -----Original Message-----
> From: scipy-user-bounces@scipy.org
[mailto:scipy-user-bounces@scipy.org] On
> 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 <t_crane@mrl.uiuc.edu> wrote:
> 
> > When using one of the ODE solvers, you can pass it a list of
arguments.
> > These arguments are used in the function that defines the system of
linear
> > equations that you're solving.  What if I want to modify an argument
every
> > iteration and re-pass this modified argument to the helper function
in the
> > 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
a
> > global variable, but I'm wondering if there's another, perhaps
better, way
> > 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.

[Trevis Crane] 

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. 

thanks,
trevis

> 
> 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?
> 
> Anne
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user


More information about the SciPy-user mailing list