Skip to content

Conversation

@ChrisRackauckas-Claude
Copy link

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Feb 8, 2026

Summary

  • Fix static_to_indices to match Base.to_indices behavior across Julia versions for multi-dimensional boolean array indices
  • Julia >= 1.12 changed Base.to_indices to return LogicalIndex{CartesianIndex{N}} for N-D boolean arrays, while Julia < 1.12 returns LogicalIndex{Int} (linear indices) for trailing boolean arrays on IndexLinear arrays
  • Uses @static if VERSION >= v"1.12-" to select the correct LogicalIndex type, ensuring compatibility with both Julia 1.10 and 1.12+

Details

On Julia 1.12, the test at test/indexing.jl:61 was failing:

to_indices: Test Failed at test/indexing.jl:61
  Expression: static_to_indices(a, (1, fill(true, 2, 2))) == Base.to_indices(a, (1, fill(true, 2, 2)))
   Evaluated: (1, [1, 2, 3, 4]) == (1, CartesianIndex{2}[CartesianIndex(1, 1), CartesianIndex(2, 1), CartesianIndex(1, 2), CartesianIndex(2, 2)])

The root cause: Base.LogicalIndex constructors return different element types based on dimensionality:

  • LogicalIndex(::AbstractVector{Bool})LogicalIndex{Int} (linear indices)
  • LogicalIndex(::AbstractArray{Bool})LogicalIndex{CartesianIndex{N}} (Cartesian indices)

Base.to_indices previously forced LogicalIndex{Int} for trailing boolean arrays on IndexLinear arrays, but Julia 1.12 changed this to use LogicalIndex(idx) which gives CartesianIndex{N} for N-D booleans.

The fix uses @static if VERSION >= v"1.12-" to match Base's behavior on each Julia version.

Note: The documentation build failure and VectorizationBase.jl/Interface/1.6 failure are pre-existing issues unrelated to this change.

Test plan

  • All tests pass on Julia 1.12.4 with JULIA_DEPWARN=error
  • Version-gated to preserve Julia 1.10 behavior
  • Verified static_to_indices output matches Base.to_indices for the affected case on Julia 1.12

🤖 Generated with Claude Code

@ChrisRackauckas-Claude
Copy link
Author

Note: CI on master has been failing since at least November 2025 on Julia 1.12 (latest), at the julia-runtest step. This is the same to_indices test failure that this PR fixes.

The CI for this PR requires maintainer approval to run (first-time fork contributor). I've verified all tests pass locally on Julia 1.12.4 with JULIA_DEPWARN=error:

Test Summary: | Pass  Total  Time
to_indices    |   23     23  1.9s

All 31 test sets pass with no failures, no deprecation warnings.

Process

  1. Cloned the repo, ran JULIA_DEPWARN=error julia --project -e 'using Pkg; Pkg.test()'
  2. Found no actual deprecation warnings in StaticArrayInterface.jl or its dependencies
  3. Found one test failure at test/indexing.jl:61 comparing static_to_indices against Base.to_indices for multi-dimensional boolean indexing
  4. Root cause: Julia 1.12 changed Base.to_indices to return LogicalIndex{CartesianIndex{N}} for N-D boolean arrays, but the IndexedMappedArray handler was forcing LogicalIndex{Int}
  5. Fixed by simplifying the handler to use LogicalIndex(idx) which naturally returns the correct type based on dimensionality
  6. Verified all tests pass

@codecov
Copy link

codecov bot commented Feb 8, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 88.55%. Comparing base (16e29eb) to head (2c6e671).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
src/indexing.jl 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #49      +/-   ##
==========================================
+ Coverage   88.45%   88.55%   +0.09%     
==========================================
  Files          11       11              
  Lines        1317     1319       +2     
==========================================
+ Hits         1165     1168       +3     
+ Misses        152      151       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Match Base.to_indices behavior across Julia versions for multi-dimensional
boolean array indexing. Julia >= 1.12 changed Base.to_indices to return
LogicalIndex{CartesianIndex{N}} for N-D boolean arrays, while Julia < 1.12
returns LogicalIndex{Int} (linear indices) for trailing boolean arrays on
IndexLinear arrays.

Use @static version check to select the correct LogicalIndex type, ensuring
static_to_indices matches Base.to_indices on both Julia 1.10 and 1.12+.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ChrisRackauckas-Claude
Copy link
Author

Updated the fix to be version-aware after CI showed the initial change broke Julia 1.10.

Root cause: Base.to_indices behavior changed between Julia versions:

  • Julia 1.10: Base.to_indices(ones(2,2,1), (1, fill(true, 2, 2)))LogicalIndex{Int}[1, 2, 3, 4]
  • Julia 1.12: Base.to_indices(ones(2,2,1), (1, fill(true, 2, 2)))LogicalIndex{CartesianIndex{2}}CartesianIndex{2}[...]

Fix: Used @static if VERSION >= v"1.12-" to select the correct LogicalIndex constructor, matching Base.to_indices behavior on each Julia version.

The pre-existing CI failures (build/docs, VectorizationBase.jl/Interface/1.6, codecov) are unrelated to this change.

@ChrisRackauckas ChrisRackauckas merged commit 2467fca into JuliaArrays:master Feb 9, 2026
7 of 10 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.

3 participants