@@ -174,13 +174,12 @@ function blockedunitrange_getindices(
174
174
a:: AbstractBlockedUnitRange , indices:: AbstractVector{Bool}
175
175
)
176
176
blocked_indices = BlockedVector (indices, axes (a))
177
- return mortar (
178
- map (Base. OneTo (blocklength (blocked_indices))) do b
179
- binds = blocked_indices[Block (b)]
180
- bstart = blockfirsts (only (axes (blocked_indices)))[b]
181
- return findall (binds) .+ (bstart - 1 )
182
- end ,
183
- )
177
+ bs = map (Base. OneTo (blocklength (blocked_indices))) do b
178
+ binds = blocked_indices[Block (b)]
179
+ bstart = blockfirsts (only (axes (blocked_indices)))[b]
180
+ return findall (binds) .+ (bstart - 1 )
181
+ end
182
+ return mortar (filter (! isempty, bs))
184
183
end
185
184
186
185
# TODO : Move this to a `BlockArraysExtensions` library.
@@ -224,12 +223,11 @@ Base.copy(a::BlockIndexVector) = BlockIndexVector(a.block, copy(a.indices))
224
223
225
224
function to_blockindices (a:: AbstractBlockedUnitRange{<:Integer} , I:: AbstractArray{Bool} )
226
225
I_blocks = blocks (BlockedVector (I, blocklengths (a)))
227
- return mortar (
228
- map (eachindex (I_blocks)) do b
229
- I_b = findall (I_blocks[b])
230
- BlockIndexVector (Block (b), I_b)
231
- end ,
232
- )
226
+ I′_blocks = map (eachindex (I_blocks)) do b
227
+ I_b = findall (I_blocks[b])
228
+ BlockIndexVector (Block (b), I_b)
229
+ end
230
+ return mortar (filter (! isempty, I′_blocks))
233
231
end
234
232
235
233
# This handles non-blocked slices.
0 commit comments