[SciPy-User] keyboard interrupt problem with odeint
Mon Apr 12 18:27:49 CDT 2010
I have a busy loop with odeint that I want to allow the user to stop,
and then have the program return gracefully. Unfortunately, when I
try to catch the KeyboardInterrupt exception, it doesn't exit or
catch it. I paired the program down to the following silly example
to reproduce the problem:
from scipy.integrate import odeint
from numpy import *
def damped_osc(u,t,b): #defines the system of odes
return(v,-x-b*v) #the derivatives of u
t = arange(0,20,0.001)
u0 = array([1,0])
u=odeint(damped_osc,u0,t,args=(b,)) #b is in tuple, needs comma
hitting control-C, I get the following printed to the screen:
error: Error occured while calling the Python function named damped_osc
but the thing keeps going!
Is there a way I can consistently stop it?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-User