Repository navigation
Make the integrator plot recipe observed-aware - #1581
ChrisRackauckas merged 1 commit into
Conversation
`plot(integrator)` threw for any system carrying symbolic metadata, and it could not resolve observed equations at all: the recipe indexed `integrator.u` directly, labelled the independent variable by indexing `variable_symbols` at `0`, never wrapped a scalar `idxs`, shared one label buffer across series, and dropped the plot function from an `idxs` tuple. Symbolic values now resolve through `SymbolicIndexingInterface`, matching the solution recipe, so the same `idxs` produces the same series and labels for an integrator as for a solution. The lookup is exposed as the public, documented `SciMLBase.symbolic_interpolation(integrator, t, idxs)`, the integrator analogue of `sol(t; idxs)`, so solver packages can route `integrator(t; idxs)` to it. `getindepsym(::DEIntegrator)` returns the first independent variable rather than the whole vector, matching its own docstring and every other method; without this, naming the independent variable in `idxs` is never recognised as the time axis. `plot_analytic = true` now raises `ArgumentError` rather than `UndefVarError` from a branch that referenced names SciMLBase does not define. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_019wKpyZHy9u4QhR4ePiVmam
|
The two red
The same failure appears on master's own run at With #1582 applied the whole group passes locally, so once that merges these two checks should go green here on a re-run. 🤖 Generated with Claude Code |
What changed and why
plot(integrator)was broken for any system that carries symbolic metadata, and it couldnot resolve observed equations at all. Reported in
SciML/ModelingToolkit.jl#5006 (comment): the
integrator recipe is not observed-aware, so a live plot cannot be updated from the
integrator the way it can from a solution.
The recipe is rewritten to follow the solution recipe: symbolic indexes are resolved
through
SymbolicIndexingInterfaceinstead of by indexingintegrator.u, so observedequations and symbolic expressions work; a scalar
idxsis wrapped the wayplot(sol; idxs = x)wraps it; the label string buffer is reset per series; the plotfunction in an
idxstuple is applied; anddimsuses the same convention as thesolution recipe so labels come out identical. A stray
@show plotton the plotting pathis removed.
The value lookup is exposed as
SciMLBase.symbolic_interpolation(integrator, t, idxs),the integrator analogue of
sol(t; idxs), together with the predicateSciMLBase.has_symbolic_idxs(idxs). Both are public and documented so that every solverpackage owning an integrator call operator can route
integrator(t; idxs)without reachinginto a SciMLBase internal or duplicating the predicate. The consumers are
SciML/OrdinaryDiffEq.jl#4469 (OrdinaryDiffEqCore and DelayDiffEq)
and the Sundials and ODEInterfaceDiffEq PRs that follow it. StochasticDiffEq needs no change
of its own:
SDEIntegratoris an alias forODEIntegrator{<:SDEAlgTypes}.Verification
plot(integrator)andintegrator(t; idxs)against the Lorenz system from the issuethread, with
w ~ x + y + zas an observed equation.Before (SciMLBase master):
After (this branch):
The new testsets in
test/downstream/plot_lines.jlcannot run at all on master — the filefails to load at
using SciMLBase: symbolic_interpolationwithUndefVarError: symbolic_interpolation not defined— so the failing-before evidence is thetable above, which exercises the same recipe paths the tests assert on.
test/downstream/plot_lines.jl, whole file, on this branch:The recipe now produces the same series labels as the solution recipe for the same
idxs:GROUP=QA:(The first QA attempt on this machine aborted at
using PythonCallbecause the localCondaPkg environment is broken; rerunning with
JULIA_CONDAPKG_BACKEND=Nulland a systemPython gives the run above. Nothing in that failure touches this change.)
Docs build (
julia --project=docs docs/make.jl, which runs withdoctest = trueandlinkcheck = true) exits 0. It caught a real problem first:is_independent_variable_indexcarried a docstring with no
@docsentry, whichmakedocstreats as fatal(
missing_docs). It is an internal predicate, so it is listed inInternal_API.mdunderInterpolation rather than promoted alongside
symbolic_interpolation. The only remainingoutput is the pre-existing
size_threshold_warnwarnings on the large interface pages.Also run: Runic
--check, clean on every file this PR touches(
src/ensemble/ensemble_solutions.jlandsrc/solutions/solution_interface.jlareunformatted on master and are deliberately left alone), and
typos.Things a reviewer should push back on
getindepsym(integrator::DEIntegrator)now returns the first independent variablerather than the whole vector. Its own docstring already documents the singular
contract, and every other method (
getindepsym(::AbstractSciMLProblem),getindepsym(::AbstractSciMLSolution)) returnssyms[1]. Without this,isequal(idx, getindepsym_defaultt(integrator))never matches, so naming theindependent variable symbolically in
idxsis not recognised as the time axis and thex-label renders as a vector.
getindepsymis@public, so this is a visible change eventhough it aligns the method with its documentation.
plot_analytic = trueon an integrator now throwsArgumentError. The previousbranch referenced
u_n,plot_timeseriesandsol, none of which exist in SciMLBase,so it could only ever have raised
UndefVarError. Erroring explicitly and pointing atintegrator.solseemed better than reimplementing a path with no users, but that is ajudgement call.
symbolic_interpolationandhas_symbolic_idxsare new public API, so this is a minorversion bump (3.51.0 → 3.52.0). Both are added to
@publicand todocs/src/interfaces/Init_Solve.mdin this PR.Not verified
Downstream packages other than OrdinaryDiffEq, the GPU and Python groups, and the full
GROUP=Downstreamsuite (onlytest/downstream/plot_lines.jlwas run). CI covers those.This PR should be ignored until reviewed by @ChrisRackauckas.
🤖 Generated with Claude Code
https://claude.ai/code/session_019wKpyZHy9u4QhR4ePiVmam