Skip to content

Conversation

@mtfishman
Copy link
Collaborator

This enables nested block indexing by generalizing BlockIndex to allow indices that aren't integers, for example:

julia> using BlockArrays

julia> a = mortar([[1, 2], [3, 4]])
2-blocked 4-element BlockVector{Int64}:
 1
 23
 4

julia> b = mortar([[5, 6], [7, 8]])
2-blocked 4-element BlockVector{Int64}:
 5
 67
 8

julia> A = mortar([a, b])
2-blocked 8-element BlockVector{Int64, Vector{BlockVector{Int64, Vector{Vector{Int64}}, Tuple{BlockedOneTo{Int64, Vector{Int64}}}}}, Tuple{BlockedOneTo{Int64, Vector{Int64}}}}:
 1
 2
 3
 45
 6
 7
 8

julia> A[Block(2)[Block(1)]]
2-element Vector{Int64}:
 5
 6

As an alternative to just generalizing BlockIndex, maybe we could define a new type such as GenericBlockIndex and then make BlockIndex a type alias for that with the indices restricted to integers. I don't have a strong opinion about that but this design was simpler and I don't see much advantage one way or another.

Related to #49 and #446, though note that in this PR the nested block structure isn't reflected in the axes, which would be required for more systematic support of nested block structures. This PR is split off from #462.

@codecov
Copy link

codecov bot commented Jul 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.53%. Comparing base (7ebbea7) to head (84227ee).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #482   +/-   ##
=======================================
  Coverage   94.52%   94.53%           
=======================================
  Files          19       19           
  Lines        1789     1810   +21     
=======================================
+ Hits         1691     1711   +20     
- Misses         98       99    +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.

@dlfivefifty
Copy link
Member

@mtfishman I'm not sure if I've done the merging correctly or what can be done to get the tests passing....

@mtfishman
Copy link
Collaborator Author

I can look into it, maybe some of the PRs conflicted with each other.

@mtfishman
Copy link
Collaborator Author

@dlfivefifty looks like it is fixed now.

@dlfivefifty dlfivefifty merged commit d482cd9 into JuliaArrays:master Oct 24, 2025
18 checks passed
@mtfishman mtfishman deleted the mf/blockindex_generalization branch October 24, 2025 11:55
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