-
Notifications
You must be signed in to change notification settings - Fork 34
New interface blocks(a) for array-of-arrays view #117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## master #117 +/- ##
==========================================
+ Coverage 84.42% 85.24% +0.81%
==========================================
Files 12 15 +3
Lines 822 935 +113
==========================================
+ Hits 694 797 +103
- Misses 128 138 +10
Continue to review full report at Codecov.
|
test/test_blocks.jl
Outdated
@test blocks(view(mortar(matrix_blocks), Block(1):Block(2), Block(2):Block(2))) == | ||
matrix_blocks[1:2, 2:2] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want special handling for SubArray
s? This currently already works because of the generic fallback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes because the generic fallback is not efficient. My primary reason for adding this (which got muddled by a tangential desire for nice printing) is for fast paths to convert subviews of a BlockMatrix{T,<:Tridiagonal}
to a BlockBandedMatrix
see JuliaLinearAlgebra/BlockBandedMatrices.jl#73
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. So I copied your code into this PR and add a few tests.
Looks good to me. Can you get the coverage up and we can merge? |
OK now Codecov seems to be happy with it. |
Base.axes(a::BlocksView) = map(br -> only(br.indices), blockaxes(a.array)) | ||
|
||
@propagate_inbounds _view(a::PseudoBlockArray, i::Block) = a[i] | ||
@propagate_inbounds _view(a::AbstractBlockArray, i::Block) = view(a, i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't hit this method with the test. But manually trying this branch with BlockBandedMatrix
seems to hit this method correctly.
Happy for me to merge this? |
I added everything I wanted to add. Please go ahead and merge this. |
Wait, why was the Compat dependency added? |
That's BlockArrays.jl/src/BlockArrays.jl Lines 42 to 44 in 42ae241
Initially, I inlined the simple definition but I thought it'd be better to use Compat. Otherwise, I needed to test the error case to make codecov happy. I can do this but I was lazy :) |
Ahh, sorry didn’t see the using statement. That’s fine |
This is an RFC to add:
It is useful for passing block arrays to some generic function that does not know the block array interfaces. For example:
After this PR, we can just do
sum_array_of_arrays(blocks(block_array))
.