@@ -360,6 +360,9 @@ bview(a, b) = Base.invoke(view, Tuple{AbstractArray,Any}, a, b)
360
360
a = randn (6 , 6 )
361
361
for mask in ([true , true , false , false , true , false ], BitVector ([true , true , false , false , true , false ]))
362
362
I = BlockedVector (mask, [3 , 3 ])
363
+ @test Base. to_index (I) == BlockedLogicalIndex (I)
364
+ @test Base. to_index (I) == [1 , 2 , 5 ]
365
+ @test Base. to_index (I) isa BlockedLogicalIndex
363
366
@test to_indices (a, (I, I)) == to_indices (a, (mask, mask))
364
367
@test to_indices (a, (I, I)) == (BlockedVector (LogicalIndex (mask), [2 , 1 ]), BlockedVector (LogicalIndex (mask), [2 , 1 ]))
365
368
@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)
372
375
@test parentindices (view (a, I, I)) == (BlockedVector ([1 , 2 , 5 ], [2 , 1 ]), BlockedVector ([1 , 2 , 5 ], [2 , 1 ]))
373
376
@test parentindices (view (a, I, I)) isa Tuple{BlockedVector{Int,Vector{Int}},BlockedVector{Int,Vector{Int}}}
374
377
@test blocklengths .(Base. axes1 .(parentindices (view (a, I, I)))) == ([2 , 1 ], [2 , 1 ])
378
+ @test sprint (show, BlockedLogicalIndex (I)) == " [1, 2, 5]"
375
379
end
380
+ bl = BlockedLogicalIndex (BlockedVector ([true , true , false , false , true , false ], [3 , 3 ]))
381
+ @test sprint (show, " text/plain" , bl) ==
382
+ " 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"
383
+ @test checkbounds (Bool, randn (6 ), bl)
384
+ @test ! checkbounds (Bool, randn (5 ), bl)
385
+ @test checkindex (Bool, 1 : 6 , bl)
386
+ @test ! checkindex (Bool, 1 : 5 , bl)
376
387
end
377
388
end
378
389
0 commit comments