Skip to content

Fix ArrayPartition A[:] DimensionMismatch (#661) - #664

Merged
ChrisRackauckas merged 2 commits into
SciML:masterfrom
ChrisRackauckas-Claude:fix-661-arraypartition-colon
Sep 26, 2026
Merged

ChrisRackauckas merged 2 commits into
SciML:masterfrom
ChrisRackauckas-Claude:fix-661-arraypartition-colon

Conversation

@ChrisRackauckas-Claude

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

Summary

A[:] on ArrayPartition was dispatching to the (colon, j...) method introduced in PR #239 with an empty j, which broadcast getindex over zero indices and threw DimensionMismatch. The fix requires at least one index after Colon (j, js...) so A[:] uses the existing flattening ::Colon method, while A[:, j...] from #239 is unchanged.

Bisect: first bad commit is ba36f16 ("Fix (colon,j...) indexing of ArrayPartition", PR #239). Parent ba36f16^ returns the flattened vector; ba36f16 breaks A[:] (initially MethodError on isless(::Int, ::Colon)); 1ce74b8b ("oops add the dispatch") changes the failure to the current DimensionMismatch.

Failing before (src fix stashed; regression testset)

DimensionMismatch: arrays could not be broadcast to a common size: a has axes Base.OneTo(2) and b has axes Base.OneTo(0)
Test Summary:                               | Pass  Error  Total  Time
ArrayPartition A[:] flattening (issue #661) |    4      9     13  5.2s

(The 4 passes are range indexing and (colon, j...) checks; all A[:] asserts error.)

Passing after

Test Summary:                               | Pass  Total  Time
ArrayPartition A[:] flattening (issue #661) |   13     13  2.3s

Test group run

GROUP=Core julia --project=. -e 'using Pkg; Pkg.test()' — passed.

Test Summary:    | Pass  Total   Time
Partitions Tests |  128    128  38.4s
...
Measurement Tests |    2      2  0.1s
     Testing RecursiveArrayTools tests passed

What was not verified

  • Downstream / AD / GPU / QA / SymbolicIndexingInterface groups
  • Behavior of setindex! with A[:] (out of scope)
  • Older Julia versions beyond 1.12.4 used here

What a reviewer should push back on

  • Whether requiring j, js... (at least one index) is the preferred fix vs making the flatten ::Colon method win on specificity another way
  • Whether nested ArrayPartition flatten via Chain is the desired semantics for A[:] in all cases
  • Docstring wording mentioning issue ArrayPartition A[:] throws DimensionMismatch #661

Fixes #661

Please ignore this draft until reviewed by @ChrisRackauckas.

Risk assessment

  • Risk: low
  • Blast radius: a single getindex(::ArrayPartition, ::Colon, j, js...) signature, tightened so that A[:] dispatches to the existing flattening getindex(::ArrayPartition, ::Colon) method. A[:, j...] behaviour is unchanged. A[:] threw on every ArrayPartition since Fix (colon,j...) indexing of ArrayPartition #239 and now returns the flattened vector. No other public API change.
  • Evidence: bisected to ba36f16 (Fix (colon,j...) indexing of ArrayPartition #239). The new tests fail on master with DimensionMismatch and pass on the PR head. I reran this independently: PR head 5/5 pass, master src gives the 2 DimensionMismatch errors.
  • Independent review: Claude Code (Opus 5.5, head session; author is Cursor Auto) rated it low, high confidence, verdict MERGE. One docstring cleanup was requested (drop the issue reference).
  • Merge: auto-merge candidate once CI is green.

🤖 Generated with Cursor Agent CLI 2026.09.26-dd393fe (model: auto), transcript /home/crackauc/sandbox/goals/issue-backlog/jobs/fix-RecursiveArrayTools.jl-661/log.txt on amdci2.julia.csail.mit.edu

Made with Cursor

Risk assessment and review by 🤖 Claude Code (model: claude-opus-5-5[1m]), https://claude.ai/code/session_01NdFVhANTF4nepTbqYxjfRP

ChrisRackauckas and others added 2 commits September 26, 2026 04:15
Require at least one index after Colon in the (colon, j...) getindex
method so A[:] dispatches to the flattening Colon method instead of
broadcasting getindex over empty indices.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Cursor Agent <[email protected]>
Agent-Harness: Cursor Agent CLI 2026.09.26-dd393fe
Agent-Model: auto
Agent-Session: local session, transcript at /home/crackauc/sandbox/goals/issue-backlog/jobs/fix-RecursiveArrayTools.jl-661/log.txt on amdci2.julia.csail.mit.edu
Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Cursor Agent <[email protected]>
Agent-Harness: Cursor Agent CLI 2026.09.26-dd393fe
Agent-Model: auto
Agent-Session: local session, transcript at /home/crackauc/sandbox/goals/issue-backlog/jobs/fix-RecursiveArrayTools.jl-661/log.txt on amdci2.julia.csail.mit.edu
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review September 26, 2026 13:01
@ChrisRackauckas
ChrisRackauckas merged commit c3a60a8 into SciML:master Sep 26, 2026
44 of 46 checks passed
ChrisRackauckas referenced this pull request Sep 26, 2026
Agent-Harness: Claude Code
Agent-Model: claude-opus-5-5[1m]
Agent-Session: local Claude Code session 3cd6500a-1f81-46b5-ac0b-c466e15b6a53 on Chris's Mac (session ID, no URL)

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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.

ArrayPartition A[:] throws DimensionMismatch

2 participants