Repository navigation
Restrict tuple nodeselect methods to integer indices - #174
Merged
ChrisRackauckas merged 1 commit intoOct 16, 2026
Merged
Conversation
The recursive tuple methods of nodeselect compare and decrement the index, so a CartesianIndex first-level index through getindex(m, i, I...) on a structure with empty values threw a MethodError. Restricting them to i::Integer sends other index types to the generic ns[i][I...] method. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Agent-Harness: Claude Code 2.1.300 Agent-Model: claude-opus-5-5 Claude-Session: https://claude.ai/code/session_01VZjwf7Ux9YtTzwHGHMqnsq
ChrisRackauckas
marked this pull request as ready for review
October 16, 2026 05:00
Merged
ChrisRackauckas
referenced
this pull request
Oct 16, 2026
Agent-Harness: Claude Code 2.1.301 Agent-Model: claude-opus-5-5 Claude-Session: https://claude.ai/code/session_01VZjwf7Ux9YtTzwHGHMqnsq Co-authored-by: Claude Opus 5.5 <noreply@anthropic.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.
Please ignore this draft until it has been reviewed by @ChrisRackauckas.
Fixes a regression from #172 (merged, unreleased); it should land before the release in #173.
What changed and why
#172 added recursive tuple methods of
nodeselectthat evaluatei == 1andi - 1on any index type. ACartesianIndexfirst-level index therefore throwsMethodError: no method matching -(::CartesianIndex{1}, ::Int64)where it used to return the element. It is reachable through publicgetindex(m, i, I...)whenm.valuesis empty, e.g.plant[CartesianIndex(2), 1, 1]. Both tuple methods now takei::Integer, so other index types go back to the genericns[i][I...]method. Both methods need the restriction: restricting only the::Tupleone makesnodeselect(::Tuple{}, ::Int, ...)ambiguous.nodeselect(([10, 20], [1.5, 2.5, 3.5]), CartesianIndex(2), 1)returns1.5again (as before #172).Verification
Regression test added to
test/tuple_nodes.jl(CartesianIndex first-level index through publicgetindexon tuple-node structures with emptyvalues, at two depths).Before (fix stashed, test present,
julia +release1.13.2):After (same file, with the fix), on both 1.13.2 and 1.10.12:
The type-stability gain from #172 is kept: the
@inferred getindex(community, 4)and@inferred getindex(scenario, 8)lines intest/tuple_nodes.jlpass on 1.13.2 and 1.10.12 (they take anIntindex, which still hits the recursive methods).GROUP=Core julia +release --project -e 'using Pkg; Pkg.test()'(1.13.2,JULIA_NUM_THREADS=4):Testing MultiScaleArrays tests passedGROUP=Core julia +lts --project -e 'using Pkg; Pkg.test()'(1.10.12):Testing MultiScaleArrays tests passedGROUP=QAon 1.13.2: passedtypos: clean.Not verified:
Core 32-bitandprelanes (left to CI). No docs changes (no public API change).Risk assessment
nodeselect(internal) viagetindex(m, i, I...)on structures with tuple nodes. Integer indices take the same path as in Make tuple-node getindex type-stable; replace @test_broken @inferred with @inferred #172; non-integer first-level indices take the pre-Make tuple-node getindex type-stable; replace @test_broken @inferred with @inferred #172 generic path. No public API change, no new dependencies.Independent reviewer's risk assessment (codex-cli 0.162.1 / gpt-6.1-sol, verdict MERGE)
getindex. Integer indices retain recursive selection; other index types use the original generic tuple indexing method. No dependencies or public signatures change.4a48db28847e9bac7db6d4bbd2182868fa0c8a89. On Julia 1.13.2 and 1.10.12, the fulltest/tuple_nodes.jlpassed 23/23 assertions, including both deep@inferredchecks. Both new CartesianIndex assertions errored with PR 172's methods restored. A 108-case comparison against pre-172 selection produced zero value/exception-type differences on either version.Test.detect_ambiguities(MultiScaleArrays; recursive=false)returned an empty list on both. CI remains pending for several lanes; no failed checks were reported when inspected.🤖 Posted by an AI agent — harness: Claude Code 2.1.300 · model: claude-opus-5-5
Conversation: https://claude.ai/code/session_01VZjwf7Ux9YtTzwHGHMqnsq
🤖 Generated with Claude Code