[SciPy-user] Behaviour of odeint

Anne Archibald peridot.faceted at gmail.com
Mon Apr 21 22:02:11 EDT 2008


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".

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 don't know that it's worth putting much effort into replicating
odeint's interface.

Anne



More information about the SciPy-User mailing list