Fix isinplace detection for Basis types (#554) #558
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes issue #554 where creating an
ODEProblemfrom aBasiswith controls would throw aMethodErrorbecause SciMLBase incorrectly detected the basis as supporting in-place evaluation.Problem
When a
Basis{false, true}(no implicit variables, with controls) was passed toODEProblem, SciMLBase'sisinplacecheck would returntrue, causing it to call the basis with a 4-argument signature(du, u, p, t). However,Basis{false, CTRLS}only supports out-of-place signatures like(u, p, t)or(u, p, t, c).The
IMPLtype parameter determines whether a basis supports in-place evaluation:IMPL=false: Out-of-place only (returns result)IMPL=true: In-place (mutates first argumentdu)Solution
Added
DiffEqBase.isinplacemethod forBasistypes:This ensures
isinplacecorrectly returnsfalseforBasis{false, CTRLS}andtrueforBasis{true, CTRLS}, based solely on whether the basis has implicit variables.Testing
isinplacenow returns correct value for bothBasis{false, false}andBasis{false, true}ODEProblemcan now be created fromBasiswithout theMethodErrorFixes #554
🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]