Repository navigation
Resolve symbolic idxs in the integrator interpolant - #126
Merged
ChrisRackauckas merged 2 commits intoSep 7, 2026
Merged
ChrisRackauckas merged 2 commits into
ChrisRackauckas merged 2 commits into
Conversation
`integrator(t; idxs = sym)` passed `idxs` straight through to `sol[idxs]`, so any symbolic index threw `ArgumentError: invalid index` and an observed equation could never be retrieved. `sol(t; idxs = sym)` has resolved both for a long time. Symbolic `idxs` now route to `SciMLBase.symbolic_interpolation`. The `nothing` comparison also becomes `===`, which is what it has to be once `idxs` can be a symbolic value that does not return a `Bool` from `==`. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019wKpyZHy9u4QhR4ePiVmam
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019wKpyZHy9u4QhR4ePiVmam
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changed and why
integrator(t; idxs = sym)passedidxsstraight through tosol[idxs], so any symbolicindex threw
ArgumentError: invalid indexand an observed equation could never be retrievedfrom an integrator.
sol(t; idxs = sym)has resolved both for a long time; this closes thesame gap that SciML/OrdinaryDiffEq.jl#4469 and
SciML/Sundials.jl#565 close for their integrators. It came up in
SciML/ModelingToolkit.jl#5006.
(integrator::ODEInterfaceIntegrator)(t; idxs)now checksSciMLBase.has_symbolic_idxsandroutes to
SciMLBase.symbolic_interpolation. Thenothingcomparison also changes from==to===: onceidxscan hold a symbolic value,idxs == nothingno longer reliablyreturns a
Bool.Depends on
SciMLBase.symbolic_interpolationandSciMLBase.has_symbolic_idxs, added inSciML/SciMLBase.jl#1585.
symbolic_interpolationshipped inSciMLBase 3.52.0, but
has_symbolic_idxsdid not make that merge, so the compat floor hereis
3.53and CI fails withUndefVarError: has_symbolic_idxs not defineduntil #1585 isregistered.
Verification
New test file
test/symbolic_interpolation_tests.jl, picked up automatically as a top-levelCore file. The ODEInterface integrator only exists inside a callback, so the symbolic
indexing is probed from an
affect!. It uses aSymbolCache, whoseExprindexes areobserved quantities, so it covers the observed path without adding ModelingToolkit to the
test target.
Before, with only the test applied and
src/reverted:After:
Both runs used SciMLBase
Pkg.developed to the branch in #1581, since the compat boundabove requires a version that is not yet registered (#1585). Runic
--checkandtyposare cleanon the files touched.
Things a reviewer should push back on
ContinuousCallbackrather than aDiscreteCallback: that is what putsthe solver into
OUTPUTFCN_DENSEmode, and without itintegrator(t)itself raises "Theevaluation of the numerical solution is not possible", independent of
idxs. There is acomment in the test saying so.
that component out of the raw output. The two agree to rounding rather than bitwise, so
the tests compare those paths with
≈.has_symbolic_idxstreatsSymbolandExpras symbolic, since that is whatSymbolicIndexingInterface.symbolic_typereports.integrator(t; idxs = :x)previouslythrew and now resolves through the symbol cache — the intended widening, but a behavior
change for anyone relying on the error.
Not verified
The rest of the ODEInterfaceDiffEq test suite, and Julia LTS. CI covers those once #1585 is
registered.
This PR should be ignored until reviewed by @ChrisRackauckas.
🤖 Generated with Claude Code
https://claude.ai/code/session_019wKpyZHy9u4QhR4ePiVmam