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: Handle y0=[] in odeint. #13278

Closed
wants to merge 1 commit into from

Conversation

WarrenWeckesser
Copy link
Member

Closes gh-13276.

@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
if nm1 == 0:
info['message'] = 'Nothing was done; the integration time was 0.'
else:
info['message'] = 'Integration successful.'
Copy link
Contributor

@mdhaber mdhaber Dec 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't nothing done even in this case? "Integration successful." doesn't sound appropriate to me when there is nothing to integrate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm preserving the invariants where len(t) == 1 gives the message 'Nothing was done...' and len(t) > 1 gives the message 'Integration successful.'. I don't think even this distinction is useful, and I'd be happy to always give a simple "success" message in any case that is not an error, but I'm copying the current behavior for the sake of consistency.

'imxer': -1,
'lenrw': 0,
'leniw': 0,
'mused': np.zeros(nm1, dtype=np.int32),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a mused value of zero documented? (I see only 1 is adams, 2 is bdf.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to return an array with the expected shape and dtype for the given length of t, but I didn't think it was meaningful to use the values 1 or 2, since neither method was actually used.

All these arrays of zeros are just placeholders put there for consistency. An alternative approach that is probably justifiable is to put the value None instead of an array. The arrays provide information about the behavior of the solver, and since a solver never ran in this edge case, maybe we shouldn't provide these arrays at all.

@WarrenWeckesser WarrenWeckesser marked this pull request as draft December 21, 2020 18:53
@WarrenWeckesser
Copy link
Member Author

I've marked this PR as "draft". While looking into gh-13276, I discovered gh-13281. We can probably fix both of these at the same time, but it might require tweaking what we put in the info dictionary in the edge cases where the underlying solver doesn't actually run. I'm looking into how to handle the edges cases cleanly while preserving backwards compatibility.

@mdhaber
Copy link
Contributor

mdhaber commented Dec 21, 2020

OK. Shall we table this until February, then?

@WarrenWeckesser
Copy link
Member Author

OK. Shall we table this until February, then?

Well, for a while, anyway. :) This isn't quite as quick a fix as I had hoped, and there's a lot of higher priority stats stuff on my to-do list.

@WarrenWeckesser
Copy link
Member Author

I'm closing this draft PR. I'll submit a new pull request with a slightly modified version of the fix proposed here.

@WarrenWeckesser
Copy link
Member Author

To avoid confusion: the PR that I just submitted, gh-20803, is not the replacement for this PR. gh-20803 addresses a different issue.

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

Successfully merging this pull request may close these issues.

odeint with empty derivative vector causes segmentation fault
2 participants