<p dir="auto">Hi, currently <code class="notranslate">scipy.integrate.ode()</code> returns an error message indicating that the function returned a tuple when it returns an array of non-matching length. The true error message is buried above the raised <code class="notranslate">ValueError</code> <a href="https://github.com/scipy/scipy/blob/03b1092cf0e0bdebcbe98a44d289208a1e597416/scipy/integrate/_ode.py#L411">here</a>, which is misleading, as the function is not returning a tuple.</p>
<p dir="auto">Could a better error message be surfaced?</p>
<h3 dir="auto">Reproducing code example:</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import scipy.integrate

def f(t, y):
    return [y[0]]

scipy.integrate.ode(f).set_initial_value([1, 1]).integrate(1)"><pre class="notranslate"><code class="notranslate">import scipy.integrate

def f(t, y):
    return [y[0]]

scipy.integrate.ode(f).set_initial_value([1, 1]).integrate(1)
</code></pre></div>
<h3 dir="auto">Error message:</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="unexpected array size: new_size=2, got array with arr_size=1
rv_cb_arr is NULL
Call-back cb_f_in_dvode__user__routines failed.
Traceback (most recent call last):
  File &quot;C:\Miniconda3\lib\site-packages\scipy\integrate\_ode.py&quot;, line 408, in integrate
    self.f_params, self.jac_params)
  File &quot;C:\Miniconda3\lib\site-packages\scipy\integrate\_ode.py&quot;, line 865, in run
    y1, t, istate = self.runner(*args)
SystemError: &lt;fortran object&gt; returned NULL without setting an error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File &quot;test.py&quot;, line 8, in &lt;module&gt;
    scipy.integrate.ode(f).set_initial_value([1, 1]).integrate(1)
  File &quot;C:\Miniconda3\lib\site-packages\scipy\integrate\_ode.py&quot;, line 411, in integrate
    raise ValueError('Function to integrate must not return a tuple.')
ValueError: Function to integrate must not return a tuple."><pre class="notranslate"><code class="notranslate">unexpected array size: new_size=2, got array with arr_size=1
rv_cb_arr is NULL
Call-back cb_f_in_dvode__user__routines failed.
Traceback (most recent call last):
  File "C:\Miniconda3\lib\site-packages\scipy\integrate\_ode.py", line 408, in integrate
    self.f_params, self.jac_params)
  File "C:\Miniconda3\lib\site-packages\scipy\integrate\_ode.py", line 865, in run
    y1, t, istate = self.runner(*args)
SystemError: &lt;fortran object&gt; returned NULL without setting an error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test.py", line 8, in &lt;module&gt;
    scipy.integrate.ode(f).set_initial_value([1, 1]).integrate(1)
  File "C:\Miniconda3\lib\site-packages\scipy\integrate\_ode.py", line 411, in integrate
    raise ValueError('Function to integrate must not return a tuple.')
ValueError: Function to integrate must not return a tuple.
</code></pre></div>
<h3 dir="auto">Scipy/Numpy/Python version information:</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="0.19.1 1.13.1 sys.version_info(major=3, minor=6, micro=1, releaselevel='final', serial=0)"><pre class="notranslate"><code class="notranslate">0.19.1 1.13.1 sys.version_info(major=3, minor=6, micro=1, releaselevel='final', serial=0)
</code></pre></div>
<p dir="auto">Hi, currently <code class="notranslate">scipy.integrate.ode()</code> returns an error message indicating that the function returned a tuple when it returns an array of non-matching length. The true error message is buried above the raised <code class="notranslate">ValueError</code> <a href="https://github.com/scipy/scipy/blob/03b1092cf0e0bdebcbe98a44d289208a1e597416/scipy/integrate/_ode.py#L411">here</a>, which is misleading, as the function is not returning a tuple.</p>
<p dir="auto">Could a better error message be surfaced?</p>
<h3 dir="auto">Reproducing code example:</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import scipy.integrate

def f(t, y):
    return [y[0]]

scipy.integrate.ode(f).set_initial_value([1, 1]).integrate(1)"><pre class="notranslate"><code class="notranslate">import scipy.integrate

def f(t, y):
    return [y[0]]

scipy.integrate.ode(f).set_initial_value([1, 1]).integrate(1)
</code></pre></div>
<h3 dir="auto">Error message:</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="unexpected array size: new_size=2, got array with arr_size=1
rv_cb_arr is NULL
Call-back cb_f_in_dvode__user__routines failed.
Traceback (most recent call last):
  File &quot;C:\Miniconda3\lib\site-packages\scipy\integrate\_ode.py&quot;, line 408, in integrate
    self.f_params, self.jac_params)
  File &quot;C:\Miniconda3\lib\site-packages\scipy\integrate\_ode.py&quot;, line 865, in run
    y1, t, istate = self.runner(*args)
SystemError: &lt;fortran object&gt; returned NULL without setting an error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File &quot;test.py&quot;, line 8, in &lt;module&gt;
    scipy.integrate.ode(f).set_initial_value([1, 1]).integrate(1)
  File &quot;C:\Miniconda3\lib\site-packages\scipy\integrate\_ode.py&quot;, line 411, in integrate
    raise ValueError('Function to integrate must not return a tuple.')
ValueError: Function to integrate must not return a tuple."><pre class="notranslate"><code class="notranslate">unexpected array size: new_size=2, got array with arr_size=1
rv_cb_arr is NULL
Call-back cb_f_in_dvode__user__routines failed.
Traceback (most recent call last):
  File "C:\Miniconda3\lib\site-packages\scipy\integrate\_ode.py", line 408, in integrate
    self.f_params, self.jac_params)
  File "C:\Miniconda3\lib\site-packages\scipy\integrate\_ode.py", line 865, in run
    y1, t, istate = self.runner(*args)
SystemError: &lt;fortran object&gt; returned NULL without setting an error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test.py", line 8, in &lt;module&gt;
    scipy.integrate.ode(f).set_initial_value([1, 1]).integrate(1)
  File "C:\Miniconda3\lib\site-packages\scipy\integrate\_ode.py", line 411, in integrate
    raise ValueError('Function to integrate must not return a tuple.')
ValueError: Function to integrate must not return a tuple.
</code></pre></div>
<h3 dir="auto">Scipy/Numpy/Python version information:</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="0.19.1 1.13.1 sys.version_info(major=3, minor=6, micro=1, releaselevel='final', serial=0)"><pre class="notranslate"><code class="notranslate">0.19.1 1.13.1 sys.version_info(major=3, minor=6, micro=1, releaselevel='final', serial=0)
</code></pre></div>