@@ -7,8 +7,12 @@ Returns the indices associated with a block as a `BlockSlice`.
7
7
"""
8
8
function unblock (A, inds, I)
9
9
B = first (I)
10
- BlockSlice (B,inds[1 ][B])
10
+ _blockslice (B, inds[1 ][B])
11
11
end
12
+
13
+ _blockslice (B, a:: AbstractUnitRange ) = BlockSlice (B, a)
14
+ _blockslice (B, a) = a # drop block structure
15
+
12
16
# Allow `ones(2)[Block(1)[1:1], Block(1)[1:1]]` which is
13
17
# similar to `ones(2)[1:1, 1:1]`.
14
18
# 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
28
32
(inds[1 ][I[1 ]], to_indices (A, _maybetail (inds), tail (I))... )
29
33
@inline to_indices (A, inds, I:: Tuple{BlockIndexRange{1,R}, Vararg{Any}} ) where R =
30
34
(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
+
31
42
32
43
# splat out higher dimensional blocks
33
44
# this mimics view of a CartesianIndex
@@ -44,6 +55,9 @@ to_index(::BlockRange) = throw(ArgumentError("BlockRange must be converted by to
44
55
@inline to_indices (A, I:: Tuple{BlockIndexRange, Vararg{Any}} ) = to_indices (A, axes (A), I)
45
56
@inline to_indices (A, I:: Tuple{Block, Vararg{Any}} ) = to_indices (A, axes (A), I)
46
57
@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)
47
61
48
62
@propagate_inbounds reindex (idxs:: Tuple{BlockSlice{<:BlockRange}, Vararg{Any}} ,
49
63
subidxs:: Tuple{BlockSlice{<:BlockIndexRange}, Vararg{Any}} ) =
0 commit comments