Skip to content

test(reduction): use sol.u[end] for state-vector output#445

Merged
ChrisRackauckas merged 2 commits intoSciML:masterfrom
ChrisRackauckas-Claude:fix-reduction-test-rat-v4
May 5, 2026
Merged

test(reduction): use sol.u[end] for state-vector output#445
ChrisRackauckas merged 2 commits intoSciML:masterfrom
ChrisRackauckas-Claude:fix-reduction-test-rat-v4

Conversation

@ChrisRackauckas-Claude
Copy link
Copy Markdown
Contributor

Note: Please ignore this PR until reviewed by @ChrisRackauckas. Opening as a draft.

Summary

Fixes the Reduction testset error reported on the arctic1-1
self-hosted runner:

Reduction: Error During Test at .../test/reduction.jl:48
  Test threw exception
  Expression: sum(sim1.u) ≈ sim2.u
  MethodError: no method matching isapprox(::Float64, ::Vector{Float64})

Root cause: under SciMLBase v3, last(sol) for a 1-component ODE
now 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])

so @test sum(sim1.u) ≈ sim2.u ends up comparing a scalar to a
1-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_func to return sol.u[end] (still a
Vector{Float64}) 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.

Test plan

  • GROUP=JLArrays julia +1.10 --project=test running the
    Reduction @safetestset:
    Test Summary: | Pass  Total   Time
    Reduction     |    3      3  24.1s
    
  • Runic format-check passes (exit 0).
  • Self-hosted CUDA runner re-runs Reduction.

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>
Comment thread test/reduction.jl Outdated
@ChrisRackauckas ChrisRackauckas marked this pull request as ready for review May 5, 2026 16:13
@ChrisRackauckas ChrisRackauckas merged commit 520dbac into SciML:master May 5, 2026
22 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants