Skip to content

Conversation

@jishnub
Copy link
Member

@jishnub jishnub commented Jun 22, 2023

This parallels the checkbounds mechanism, except for Blocks. On master,

julia> B = BlockArray(zeros(6,6), 1:3, 1:3);

julia> blockcheckbounds(B, 4)
ERROR: MethodError: no method matching blockcheckbounds(::BlockMatrix{Float64, Matrix{Matrix{Float64}}, Tuple{BlockedUnitRange{ArrayLayouts.RangeCumsum{Int64, UnitRange{Int64}}}, BlockedUnitRange{ArrayLayouts.RangeCumsum{Int64, UnitRange{Int64}}}}}, ::Int64)
[...]

julia> B[Block(4)]
1×2 Matrix{Float64}:
 0.0  0.0

This is because linear Block indexing wasn't supported in blockcheckbounds. This is fixed now.

julia> blockcheckbounds(B, 4)
true

After this, blockcheckbounds_indices performs the bounds check for Cartesian indexing using Blocks, and calls blockcheckindex internally. On the other hand, blockcheckindex is called directly for linear indexing.

This also relaxes the signature of blockcheckbounds to make the following consistent:

julia> B[Block(1,1,1)]
1×1×1 Array{Float64, 3}:
[:, :, 1] =
 0.0

julia> blockcheckbounds(B, 1,1,1)
true

@codecov
Copy link

codecov bot commented Jun 22, 2023

Codecov Report

Merging #269 (308641f) into master (92e81ef) will increase coverage by 0.27%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #269      +/-   ##
==========================================
+ Coverage   91.86%   92.13%   +0.27%     
==========================================
  Files          16       16              
  Lines        1475     1475              
==========================================
+ Hits         1355     1359       +4     
+ Misses        120      116       -4     
Impacted Files Coverage Δ
src/abstractblockarray.jl 96.05% <100.00%> (+2.54%) ⬆️

... and 5 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@jishnub jishnub force-pushed the blockcheckbounds branch from db073d0 to a96f027 Compare June 23, 2023 06:37
@jishnub jishnub merged commit 4c0e4e9 into JuliaArrays:master Jun 27, 2023
@jishnub jishnub deleted the blockcheckbounds branch June 27, 2023 07:24
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.

1 participant