[SciPy-user] Behaviour of odeint

Gabriel Gellner ggellner at uoguelph.ca
Mon Apr 21 23:56:00 EDT 2008


On Mon, Apr 21, 2008 at 10:02:11PM -0400, Anne Archibald wrote:
> On 21/04/2008, Gabriel Gellner <ggellner at uoguelph.ca> wrote:
> > I just noticed that when you send odeint an empty array, it returns an empty
> >  array (that is it doesn't raise and error), is this intentional?
> >
> >  I noticed similarly with array functions like numpy.sin, have the same
> >  behaviour. Can anyone shed light on the logic behind this, I find in
> >  confusing, but I am easily convince ;-)
> 
> For numpy.sin and friends (ufuncs) the idea is that these functions
> act elementwise on arrays; you can get the same effect in pure python
> with, for example,
> 
> map(math.sin, list)
> or
> [sin(x) for x in list]
> 
> In both cases it's clear that the empty list means "do nothing".
> 
Ahhh, the list comprehension makes it clear to me! Thanks! 

> For odeint I'm not so convinced; since you normally need to supply it
> with the starting time, plus any times you want it to integrate to, it
> seems like calling it with an empty list is always an error. Still, I
> suppose I can imagine some application for odeint working on an empty
> list.
> 
I agree I have decided this is a miss feature. Also matlab raises and error, 
and yet has the previous behavior so at least one other group agrees :-)

> I don't know that it's worth putting much effort into replicating
> odeint's interface.
> 
Nah, but I don't want to mess things up for no reason.

Gabriel



More information about the SciPy-User mailing list