Skip to content

Conversation

mtfishman
Copy link
Collaborator

This introduces a blocked version of logical indexing. With this PR, if you index into array with an AbstractBlockVector{Bool}, it is interpreted as a logical index but also uses the blocking of the index to determine the block structure of the output array, for example:

julia> using BlockArrays

julia> a = randn(6, 6)
6×6 Matrix{Float64}:
 -0.0577235  -0.12942   -0.10982    1.01086    0.196898   0.896616
 -0.163481   -1.24784    1.01413    0.244657  -0.49961   -0.435926
  1.64239    -0.930051  -0.923835  -0.789608  -0.53113   -0.0502656
  0.0999888  -2.41073   -2.03078    0.019679  -0.857197   0.188939
 -0.698236   -0.218804  -1.36086    0.77242    0.1388     1.97166
  1.77482    -1.58258   -0.042804   1.30733    1.33004    0.930145

julia> mask = [true, true, false, false, true, false]
6-element Vector{Bool}:
 1
 1
 0
 0
 1
 0

julia> I = BlockedVector(mask, [3, 3])
2-blocked 6-element BlockedVector{Bool}:
 1
 1
 00
 1
 0

julia> a[I, I]
2×2-blocked 3×3 BlockedMatrix{Float64}:
 -0.0577235  -0.129420.196898
 -0.163481   -1.24784-0.49961 
 ───────────────────────┼───────────
 -0.698236   -0.2188040.1388  

Without this PR, the output of a[I, I] would not have been blocked.

Copy link

codecov bot commented Jul 7, 2025

Codecov Report

Attention: Patch coverage is 73.33333% with 4 lines in your changes missing coverage. Please review.

Project coverage is 93.65%. Comparing base (e9c28d4) to head (a01c225).
Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
src/views.jl 71.42% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master     #475       +/-   ##
===========================================
+ Coverage    0.00%   93.65%   +93.65%     
===========================================
  Files          19       19               
  Lines        1689     1719       +30     
===========================================
+ Hits            0     1610     +1610     
+ Misses       1689      109     -1580     

☔ 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 dlfivefifty merged commit b717822 into JuliaArrays:master Jul 10, 2025
16 checks passed
@mtfishman mtfishman deleted the mf/blockedlogicalindex branch July 10, 2025 17:54
mtfishman added a commit that referenced this pull request Jul 10, 2025
I noticed #475 had some missing test coverage, this should fix that.
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