diff --git a/src/views.jl b/src/views.jl index 157acbe5..d66834e1 100644 --- a/src/views.jl +++ b/src/views.jl @@ -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) diff --git a/test/test_blockarrays.jl b/test/test_blockarrays.jl index 6a5dc6e7..286bba42 100644 --- a/test/test_blockarrays.jl +++ b/test/test_blockarrays.jl @@ -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]