Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: integrate: Exception raised by odeint when t=[] and full_output is True. #13281

Open
WarrenWeckesser opened this issue Dec 21, 2020 · 0 comments
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.integrate

Comments

@WarrenWeckesser
Copy link
Member

An invariant of a call of odeint(func, y0, t) is that the output has shape (n, d) where n is len(t) and d is len(y0). This includes the edge case where t = []:

In [41]: odeint(lambda x, t: -x, [3], [])                                                                               
Out[41]: array([], shape=(0, 1), dtype=float64)

However, if full_ouput is True in this case, an exception is raised:

In [42]: odeint(lambda x, t: -x, [3], [], full_output=True)                                                             
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-42-46d3f4c22fe0> in <module>
----> 1 odeint(lambda x, t: -x, [3], [], full_output=True)

~/mc37allpip/lib/python3.7/site-packages/scipy-1.7.0.dev0+624fd76-py3.7-macosx-10.9-x86_64.egg/scipy/integrate/odepack.py in odeint(func, y0, t, args, Dfun, col_deriv, full_output, ml, mu, rtol, atol, tcrit, h0, hmax, hmin, ixpr, mxstep, mxhnil, mxordn, mxords, printmessg, tfirst)
    255                              full_output, rtol, atol, tcrit, h0, hmax, hmin,
    256                              ixpr, mxstep, mxhnil, mxordn, mxords,
--> 257                              int(bool(tfirst)))
    258     if output[-1] < 0:
    259         warning_msg = _msgs[output[-1]] + " Run with full_output = 1 to get quantitative information."

ValueError: negative dimensions are not allowed

The problem is that when full_output is True, a dictionary containing information about the behavior of the solver is created, and some of the values in this dictionary are arrays with length n - 1. When t = [], n is 0 and the attempt to create the arrays for the dictionary fail.

@WarrenWeckesser WarrenWeckesser added defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.integrate labels Dec 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.integrate
Projects
None yet
Development

No branches or pull requests

1 participant