Skip to content

Commit 7ca3801

Browse files
committed
More progress
1 parent 485185d commit 7ca3801

File tree

3 files changed

+29
-15
lines changed

3 files changed

+29
-15
lines changed

src/BlockArraysExtensions/BlockArraysExtensions.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,14 @@ const BlockIndexRangeSlices = BlockIndices{
167167
const BlockIndexVectorSlices = BlockIndices{
168168
<:BlockVector{<:BlockIndex{1},<:Vector{<:BlockIndexVector}}
169169
}
170+
const GenericBlockIndexVectorSlices = BlockIndices{
171+
<:BlockVector{<:GenericBlockIndex{1},<:Vector{<:BlockIndexVector}}
172+
}
170173
const SubBlockSliceCollection = Union{
171-
BlockIndexRangeSlice,BlockIndexRangeSlices,BlockIndexVectorSlices
174+
BlockIndexRangeSlice,
175+
BlockIndexRangeSlices,
176+
BlockIndexVectorSlices,
177+
GenericBlockIndexVectorSlices,
172178
}
173179

174180
# TODO: This is type piracy. This is used in `reindex` when making

src/BlockArraysExtensions/blockedunitrange.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -176,19 +176,6 @@ function blockedunitrange_getindices(
176176
return mortar(map(b -> a[b], blocks(indices)))
177177
end
178178

179-
function blockedunitrange_getindices(
180-
a::AbstractBlockedUnitRange,
181-
indices::BlockVector{<:BlockIndex{1},<:Vector{<:BlockIndexVector{1}}},
182-
)
183-
return mortar(map(b -> a[b], blocks(indices)))
184-
end
185-
function blockedunitrange_getindices(
186-
a::AbstractBlockedUnitRange,
187-
indices::BlockVector{<:GenericBlockIndex{1},<:Vector{<:BlockIndexVector{1}}},
188-
)
189-
return mortar(map(b -> a[b], blocks(indices)))
190-
end
191-
192179
function blockedunitrange_getindices(
193180
a::AbstractBlockedUnitRange, indices::AbstractVector{Bool}
194181
)
@@ -345,6 +332,19 @@ using ArrayLayouts: LayoutArray
345332
K
346333
)][K.indices...]
347334

335+
function blockedunitrange_getindices(
336+
a::AbstractBlockedUnitRange,
337+
indices::BlockVector{<:BlockIndex{1},<:Vector{<:BlockIndexVector{1}}},
338+
)
339+
return mortar(map(b -> a[b], blocks(indices)))
340+
end
341+
function blockedunitrange_getindices(
342+
a::AbstractBlockedUnitRange,
343+
indices::BlockVector{<:GenericBlockIndex{1},<:Vector{<:BlockIndexVector{1}}},
344+
)
345+
return mortar(map(b -> a[b], blocks(indices)))
346+
end
347+
348348
function to_blockindices(a::AbstractBlockedUnitRange{<:Integer}, I::AbstractArray{Bool})
349349
I_blocks = blocks(BlockedVector(I, blocklengths(a)))
350350
I′_blocks = map(eachindex(I_blocks)) do b

src/abstractblocksparsearray/views.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ function BlockArrays.viewblock(
166166
<:AbstractBlockSparseArray{T,N},
167167
<:Tuple{Vararg{Union{BlockSliceCollection,SubBlockSliceCollection},N}},
168168
},
169-
block::Union{Block{N},BlockIndexRange{N}},
169+
block::Union{Block{N},BlockIndexRange{N},BlockIndexVector{N}},
170170
) where {T,N}
171171
return viewblock(a, to_tuple(block)...)
172172
end
@@ -228,6 +228,14 @@ function to_blockindexrange(
228228
# work right now.
229229
return blocks(a.blocks)[Int(I)]
230230
end
231+
function to_blockindexrange(
232+
a::BlockIndices{<:BlockVector{<:GenericBlockIndex{1},<:Vector{<:BlockIndexVector}}},
233+
I::Block{1},
234+
)
235+
# TODO: Ideally we would just use `a.blocks[I]` but that doesn't
236+
# work right now.
237+
return blocks(a.blocks)[Int(I)]
238+
end
231239
function to_blockindexrange(
232240
a::Base.Slice{<:AbstractBlockedUnitRange{<:Integer}}, I::Block{1}
233241
)

0 commit comments

Comments
 (0)