Skip to content

Preserve SLArray labels when restructuring - #220

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:codex/fix-sizedarray-label-preservation
Aug 31, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:codex/fix-sizedarray-label-preservation

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Ignore this PR until it has been reviewed by @ChrisRackauckas. This draft is not ready for merge.

What changed and why

Add an ArrayInterface.restructure specialization for immutable SLArray states so rebuilding a state from a flat linear-solve result preserves its shape and labels. Add a focused inferred regression test for the public restructuring interface.

OrdinaryDiffEq commit 100fe2369ce04be7a78084eb1d599254454f7ef3, first released in OrdinaryDiffEqRosenbrock 2.6.1, changed out-of-place stiff stages from reshape to the public ArrayInterface.restructure API. The generic implementation allocates through similar, which intentionally produces a mutable LArray for an SLArray template; FastBroadcast subsequently materializes a label-less SizedVector, causing labelled ODE right-hand sides to fail with SizedArray has no field y.

Failing before / passing after

Focused command:

julia +1 --startup-file=no --project=. test/slarrays.jl

Before the source fix, with only the regression assertion applied:

Basic interface: Test Failed
Expression: @inferred(ArrayInterface.restructure(b, SVector(1.0, 2.0, 3.0))) ===
            ABC_fl(1.0, 2.0, 3.0)
Evaluated: LArray{Float64, 1, Vector{Float64}, (:a, :b, :c)} ===
           SLArray{Tuple{3}, Float64, 1, 3, (:a, :b, :c)}
Test Summary:   | Pass  Fail  Total
Basic interface |   23     1     24

After the fix:

Test Summary:   | Pass  Total
Basic interface |   24     24
NamedTuple conversion | 7 7
accessing labels, i.e. symbols | 1 1
Explicit indices | 12 12
Concatenate and Iterate | 2 2
convert | 2 2
recursive_unitless_eltype | 1 1

The original integration regression was also reproduced before the fix:

FieldError: type StaticArraysCore.SizedArray has no field `y`, available fields: `data`
Test Summary:  | Error  Total
Core/diffeq.jl |     1      1

Verification

Public API evidence and full Core group:

GROUP=Core julia +1 --startup-file=no --project=. -e 'using ArrayInterface; println("ArrayInterface.restructure public = ", Base.ispublic(ArrayInterface, :restructure)); using Pkg; Pkg.test()'
ArrayInterface.restructure public = true
Test Summary:      | Pass  Total
Core/chainrules.jl |   50     50
Core/diffeq.jl | 9 9
Core/larrays.jl | 74 pass, 4 pre-existing broken, 78 total
Core/recursivearraytools.jl | 2 2
Core/slarrays.jl | 49 49
Testing LabelledArrays tests passed

QA group:

GROUP=QA julia +1 --startup-file=no --project=. -e 'using Pkg; Pkg.test()'
Test Summary: | Pass  Total   Time
QA/qa.jl      |   20     20  38.9s
Testing LabelledArrays tests passed

Formatting and spelling:

julia +1 --startup-file=no -m Runic --check --diff src/slarray.jl test/slarrays.jl
typos src/slarray.jl test/slarrays.jl

Both exited successfully with no output.

Not verified locally

  • Core on Julia LTS and Julia pre-release.
  • QA on Julia LTS.
  • The Julia 1 AllocCheck group.
  • The Julia 1 RecursiveArrayTools group outside the Core selection.
  • Hosted CI lanes and platform-specific runners.
  • Documentation build; this change adds no new public name or documentation content.

Links

🤖 Generated with Codex CLI 0.151.0 (model: gpt-5.6-sol; session: local session ID 01a0598f-11b9-72d1-91d9-b2fbb186557d)

Teach the public ArrayInterface.restructure API to rebuild immutable SLArray states with their original shape and labels. This keeps out-of-place stiff solver stages labelled after a flat linear solve.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: OpenAI Codex <noreply@openai.com>
Agent-Harness: Codex CLI 0.151.0
Agent-Model: gpt-5.6-sol
Agent-Session: local session ID 01a0598f-11b9-72d1-91d9-b2fbb186557d
@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member Author

The Runic failure is a pre-existing default-branch failure, not introduced by this behavior change. Current master fails the same whole-repository formatter check at test/qa/qa.jl: https://github.com/SciML/LabelledArrays.jl/actions/runs/33065304019. The PR job reports the identical diff: https://github.com/SciML/LabelledArrays.jl/actions/runs/33445277093/job/99662853754. I am keeping that mechanical formatting correction out of this behavior PR, as required; it will be investigated and shipped separately.

@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review August 31, 2026 22:24
@ChrisRackauckas
ChrisRackauckas merged commit c1362d4 into SciML:master Aug 31, 2026
11 of 12 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