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

SciPy Trac scipy-tickets@scipy....
Mon Nov 14 02:27:47 CST 2011

#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 pearu):

 f2py supports user-defined functions that have multiple return values.
 These return values are expected to be returned as a single tuple object.
 So, the issue here is not a result of f2py bug but due to this f2py
 that is unintentionally triggered by the given example.

 As a possible fix, we could have the f2py code to treat the returned
 as ordinary sequences when the expected number of returned values is
 exactly 1.
 On the other hand, in the case of f2py misuse (returning 2 values when 1
 is expected,
 for instance) the values will be silently converted to an array and may
 even a more complicated issues to be analyzed.

 I think the best fix is to document this f2py feature in the corresponding
 codes, that is, never return tuple as a single return value,
 and perhaps improve the error message giving a hint why the crash might
 have been occurred.

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

More information about the Scipy-tickets mailing list