diff --git a/src/views.jl b/src/views.jl index 3ebb9b54..5b0dbb80 100644 --- a/src/views.jl +++ b/src/views.jl @@ -111,7 +111,6 @@ collect(I::BlockedLogicalIndex) = collect(I.blocks) checkbounds(::Type{Bool}, A::AbstractArray, i::BlockedLogicalIndex) = checkbounds(Bool, A, i.blocks.mask) # `checkbounds_indices` has been handled via `I::AbstractArray` fallback checkindex(::Type{Bool}, inds::AbstractUnitRange, i::BlockedLogicalIndex) = checkindex(Bool, inds, i.blocks.mask) -checkindex(::Type{Bool}, inds::Tuple, i::BlockedLogicalIndex) = checkindex(Bool, inds, i.blocks.mask) # Instantiate the BlockedLogicalIndex when constructing a SubArray, similar to # `ensure_indexable(I::Tuple{LogicalIndex,Vararg{Any}})`: diff --git a/test/test_blockviews.jl b/test/test_blockviews.jl index aac1fd5f..4dc6c710 100644 --- a/test/test_blockviews.jl +++ b/test/test_blockviews.jl @@ -360,6 +360,9 @@ bview(a, b) = Base.invoke(view, Tuple{AbstractArray,Any}, a, b) a = randn(6, 6) for mask in ([true, true, false, false, true, false], BitVector([true, true, false, false, true, false])) I = BlockedVector(mask, [3, 3]) + @test Base.to_index(I) == BlockedLogicalIndex(I) + @test Base.to_index(I) == [1, 2, 5] + @test Base.to_index(I) isa BlockedLogicalIndex @test to_indices(a, (I, I)) == to_indices(a, (mask, mask)) @test to_indices(a, (I, I)) == (BlockedVector(LogicalIndex(mask), [2, 1]), BlockedVector(LogicalIndex(mask), [2, 1])) @test to_indices(a, (I, I)) isa Tuple{BlockedLogicalIndex{Int},BlockedLogicalIndex{Int}} @@ -372,7 +375,15 @@ bview(a, b) = Base.invoke(view, Tuple{AbstractArray,Any}, a, b) @test parentindices(view(a, I, I)) == (BlockedVector([1, 2, 5], [2, 1]), BlockedVector([1, 2, 5], [2, 1])) @test parentindices(view(a, I, I)) isa Tuple{BlockedVector{Int,Vector{Int}},BlockedVector{Int,Vector{Int}}} @test blocklengths.(Base.axes1.(parentindices(view(a, I, I)))) == ([2, 1], [2, 1]) + @test sprint(show, BlockedLogicalIndex(I)) == "[1, 2, 5]" end + bl = BlockedLogicalIndex(BlockedVector([true, true, false, false, true, false], [3, 3])) + @test sprint(show, "text/plain", bl) == + "2-blocked 3-element BlockedVector{Int64, Base.LogicalIndex{Int64, BlockedVector{Bool, Vector{Bool}, Tuple{BlockedOneTo{Int64, Vector{Int64}}}}}, Tuple{BlockedOneTo{Int64, Vector{Int64}}}}:\n 1\n 2\n ─\n 5" + @test checkbounds(Bool, randn(6), bl) + @test !checkbounds(Bool, randn(5), bl) + @test checkindex(Bool, 1:6, bl) + @test !checkindex(Bool, 1:5, bl) end end