Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/views.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ to_index(::BlockRange) = throw(ArgumentError("BlockRange must be converted by to

# In 0.7, we need to override to_indices to avoid calling linearindices
@inline to_indices(A, I::Tuple{BlockIndexRange, Vararg{Any}}) = to_indices(A, axes(A), I)
@inline to_indices(A, I::Tuple{BlockIndex, Vararg{Any}}) = to_indices(A, axes(A), I)
@inline to_indices(A, I::Tuple{Block, Vararg{Any}}) = to_indices(A, axes(A), I)
@inline to_indices(A, I::Tuple{BlockRange, Vararg{Any}}) = to_indices(A, axes(A), I)
@inline to_indices(A, I::Tuple{AbstractVector{<:Block{1}}, Vararg{Any}}) = to_indices(A, axes(A), I)
Expand Down
3 changes: 3 additions & 0 deletions test/test_blockarrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -961,9 +961,12 @@ end
@testset "Blockindex" begin
a = BlockedArray(randn(3), [1,2])
@test a[Block(1)[1]] == a[1]
@test view(a, Block(1)[1]) view(a, 1)
@test a[Block(1)[1:1]] == a[1:1]
A = BlockedArray(randn(3,3), [1,2], [1,2])
@test A[Block(1)[1], Block(1)[1]] == A[Block(1,1)[1,1]] == A[1,1]
# Regression test for #442
@test view(A, Block(1)[1], Block(1)[1]) view(A, Block(1,1)[1,1]) view(A, 1, 1)
@test A[Block(1)[1:1], Block(1)[1:1]] == A[Block(1,1)[1:1,1:1]] == A[1:1,1:1]
@test A[Block(1)[1:1], Block(1)[1]] == BlockArray(A)[Block(1)[1:1], Block(1)[1]] == A[1:1,1]
@test A[Block(1)[1], Block(1)[1:1]] == BlockArray(A)[Block(1)[1], Block(1)[1:1]] == A[1,1:1]
Expand Down
Loading