@@ -7,8 +7,12 @@ Returns the indices associated with a block as a `BlockSlice`.
77"""
88function unblock (A, inds, I)
99 B = first (I)
10- BlockSlice (B,inds[1 ][B])
10+ _blockslice (B, inds[1 ][B])
1111end
12+
13+ _blockslice (B, a:: AbstractUnitRange ) = BlockSlice (B, a)
14+ _blockslice (B, a) = a # drop block structure
15+
1216# Allow `ones(2)[Block(1)[1:1], Block(1)[1:1]]` which is
1317# similar to `ones(2)[1:1, 1:1]`.
1418# Need to check the length of I in case its empty
@@ -28,6 +32,13 @@ to_index(::BlockRange) = throw(ArgumentError("BlockRange must be converted by to
2832 (inds[1 ][I[1 ]], to_indices (A, _maybetail (inds), tail (I))... )
2933@inline to_indices (A, inds, I:: Tuple{BlockIndexRange{1,R}, Vararg{Any}} ) where R =
3034 (unblock (A, inds, I), to_indices (A, _maybetail (inds), tail (I))... )
35+ @inline to_indices (A, inds, I:: Tuple{AbstractVector{Block{1,R}}, Vararg{Any}} ) where R =
36+ (unblock (A, inds, I), to_indices (A, _maybetail (inds), tail (I))... )
37+ @inline to_indices (A, inds, I:: Tuple{AbstractVector{<:BlockIndex{1}}, Vararg{Any}} ) =
38+ (unblock (A, inds, I), to_indices (A, _maybetail (inds), tail (I))... )
39+ @inline to_indices (A, inds, I:: Tuple{AbstractVector{<:BlockIndexRange{1}}, Vararg{Any}} ) =
40+ (unblock (A, inds, I), to_indices (A, _maybetail (inds), tail (I))... )
41+
3142
3243# splat out higher dimensional blocks
3344# this mimics view of a CartesianIndex
@@ -44,6 +55,9 @@ to_index(::BlockRange) = throw(ArgumentError("BlockRange must be converted by to
4455@inline to_indices (A, I:: Tuple{BlockIndexRange, Vararg{Any}} ) = to_indices (A, axes (A), I)
4556@inline to_indices (A, I:: Tuple{Block, Vararg{Any}} ) = to_indices (A, axes (A), I)
4657@inline to_indices (A, I:: Tuple{BlockRange, Vararg{Any}} ) = to_indices (A, axes (A), I)
58+ @inline to_indices (A, I:: Tuple{AbstractVector{<:Block{1}}, Vararg{Any}} ) = to_indices (A, axes (A), I)
59+ @inline to_indices (A, I:: Tuple{AbstractVector{<:BlockIndex{1}}, Vararg{Any}} ) = to_indices (A, axes (A), I)
60+ @inline to_indices (A, I:: Tuple{AbstractVector{<:BlockIndexRange{1}}, Vararg{Any}} ) = to_indices (A, axes (A), I)
4761
4862@propagate_inbounds reindex (idxs:: Tuple{BlockSlice{<:BlockRange}, Vararg{Any}} ,
4963 subidxs:: Tuple{BlockSlice{<:BlockIndexRange}, Vararg{Any}} ) =
0 commit comments