[Scipy-tickets] [SciPy] #1187: ode crashes if rhs returns a tuple instead of a list

SciPy Trac scipy-tickets@scipy....
Fri Dec 21 16:31:14 CST 2012


#1187: ode crashes if rhs returns a tuple instead of a list
--------------------------------------------------------+-------------------
 Reporter:  miha                                        |       Owner:  somebody   
     Type:  defect                                      |      Status:  new        
 Priority:  normal                                      |   Milestone:  Unscheduled
Component:  scipy.integrate                             |     Version:  0.7.0      
 Keywords:  integrade, ode, PyObject_Call, tuple, list  |  
--------------------------------------------------------+-------------------

Comment(by RhysU):

 Appears to not just be related to tuple-vs-list.  The following
 {{{
 import numpy as np
 import numpy.random
 import scipy.integrate.ode
 import matplotlib.pyplot as plt

 # Given state [x, y, z] compute right hand side of the Lorenz equations.
 # The default coefficients compute the canonical attractor.
 def lorenz(t, xyz, coefficients = [10., 8./3., 28.]):
     x, y, z = xyz
     sigma, beta, rho = coefficients
     return [ sigma*(y-x), x*(rho-z)-y, x*y-beta*z ]

 def lorenz_compute(tf = 1000, dt = 0.1, xyz0 = np.random.randn(3)):
     solver = scipy.integrate.ode(lorenz_compute)
     solver.set_integrator('vode')
     solver.set_initial_value(xyz0, 0)
     soln = []
     while solver.successful() and solver.t < tf:
         solver.integrate(solver.t + dt)
         soln.append([solver.t, solver.y[0], solver.y[1], solver.y[2]])
     return np.array(soln)

 if __name__ == "__main__":
     a = lorenz_compute()
 }}}
 bombs out with
 {{{
 [4883 rhys@setun lorenz]$ python sample.py
 unexpected array size: new_size=3, got array with arr_size=0
 rv_cb_arr is NULL
 Call-back cb_f_in_dvode__user__routines failed.
 Traceback (most recent call last):
   File "sample.py", line 24, in <module>
     a = lorenz_compute()
   File "sample.py", line 19, in lorenz_compute
     solver.integrate(solver.t + dt)
   File "/usr/lib/python2.6/dist-packages/scipy/integrate/ode.py", line
 260, in integrate
     self.f_params,self.jac_params)
   File "/usr/lib/python2.6/dist-packages/scipy/integrate/ode.py", line
 435, in run
     y1,t,istate = self.runner(*(args[:5]+tuple(self.call_args)+args[5:]))
 SystemError: NULL result without error in PyObject_Call
 }}}
 Notice the lack of tuple-vs-list-iness in function lorenz.

-- 
Ticket URL: <http://projects.scipy.org/scipy/ticket/1187#comment:7>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list