[SciPy-user] Bug in scipy.integrate.ode?

LATORNELL, Doug Doug.LATORNELL at mdsinc.com
Wed Mar 15 17:47:05 CST 2006


In [2]: numpy.__version__
Out[2]: '0.9.7.2247'

In [4]: scipy.__version__
Out[4]: '0.4.7.1711'

Trivial integration of a decaying exponential:

from scipy import *

def f(t, y):
    return -log(2) / 2 * y


r = integrate.ode(f).set_integrator('vode')
r.set_initial_value(1.0)
while r.successful() and r.t <= 2:
    r.integrate(r.t + 0.1)
    print r.t, r.y

Produces:

Python 2.4.1 (#1, Sep  3 2005, 13:08:59) 
Type "copyright", "credits" or "license" for more information.

IPython 0.6.15 -- An enhanced Interactive Python.
?       -> Introduction to IPython's features.
%magic  -> Information about IPython's 'magic' % functions.
help    -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.

In [1]: ## working on region in file /tmp/python-23462ATK.py...
Found integrator vode
------------------------------------------------------------------------
---
exceptions.NameError                                 Traceback (most
recent call last)

/home/doug/python/<console> 

/tmp/python-23462ATK.py 
      6 
      7 r = integrate.ode(f).set_integrator('vode')
----> 8 r.set_initial_value(1.0)
      9 while r.successful() and r.t <= 2:
     10     r.integrate(r.t + 0.1)

/usr/local/lib/python2.4/site-packages/scipy/integrate/ode.py in
set_initial_value(self, y, t)
    141     def set_initial_value(self,y,t=0.0):
    142         """Set initial conditions y(t) = y."""
--> 143         if isscalar(y):
    144             y = [y]
    145         n_prev = len(self.y)

NameError: global name 'isscalar' is not defined

The fix appears to be to add 'isscalar' to the 'from numpy import ...'
at line 94 in scipy/integrate/ode.py

Doug



This email and any files transmitted with it may contain privileged or confidential information and may be read or used only by the intended recipient.  If you are not the intended recipient of the email or any of its attachments, please be advised that you have received this email in error and any use, dissemination, distribution, forwarding, printing or copying of this email or any attached files is strictly prohibited.  If you have received this email in error, please immediately purge it and all attachments and notify the sender by reply email or contact the sender at the number listed.



More information about the SciPy-user mailing list