test(reduction): use sol.u[end] for state-vector output#445
Merged
ChrisRackauckas merged 2 commits intoSciML:masterfrom May 5, 2026
Merged
Conversation
Under SciMLBase v3, `last(sol)` for a 1-component ODE returns a
`Float64` scalar rather than a 1-element `Vector{Float64}`. With the
existing `output_func`, that flowed through to:
- `sim1.u :: Vector{Float64}` (was Vector{Vector{Float64}})
- `sum(sim1.u) :: Float64` (was Vector{Float64})
- `sim2.u :: Vector{Float64}` (1-element, from `u_init = [0.0]`)
making `@test sum(sim1.u) ≈ sim2.u` fail with:
MethodError: no method matching isapprox(::Float64, ::Vector{Float64})
i.e. the test wasn't migrated correctly when the rest of the suite
moved to SciMLBase v3 / RecursiveArrayTools v4.
Switching to `sol.u[end]` keeps each per-trajectory output as a
state vector, restoring the original shape semantics so the three
existing assertions hold without relaxing what they check.
Verified locally with `GROUP=JLArrays`:
Test Summary: | Pass Total Time
Reduction | 3 3 24.1s
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
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.
Note: Please ignore this PR until reviewed by @ChrisRackauckas. Opening as a draft.
Summary
Fixes the
Reductiontestset error reported on thearctic1-1self-hosted runner:
Root cause: under SciMLBase v3,
last(sol)for a 1-component ODEnow returns a
Float64scalar rather than a 1-elementVector{Float64}. With the existingoutput_functhat flowedthrough to:
sim1.u :: Vector{Float64}(wasVector{Vector{Float64}})sum(sim1.u) :: Float64(wasVector{Float64})sim2.u :: Vector{Float64}(1-element, fromu_init = [0.0])so
@test sum(sim1.u) ≈ sim2.uends up comparing a scalar to a1-element vector and errors. The test file wasn't migrated for the
shape change when the rest of the suite moved to SciMLBase v3 /
RAT v4.
Switching
output_functo returnsol.u[end](still aVector{Float64}) keeps each per-trajectory output as a statevector, restoring the original shape semantics so the three
existing assertions hold without relaxing what they check.
Test plan
GROUP=JLArrays julia +1.10 --project=testrunning theReduction@safetestset:exit 0).Reduction.