Skip to content

Commit 5944fb6

Browse files
committed
Fix tests
1 parent ad8c6b2 commit 5944fb6

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

src/BlockArraysExtensions/BlockArraysExtensions.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,10 @@ end
180180
# ```
181181
# but includes `BlockIndices`, where the blocks aren't contiguous.
182182
const BlockSliceCollection = Union{
183-
Base.Slice,BlockSlice{<:BlockRange{1}},BlockIndices{<:Vector{<:Block{1}}}
183+
Base.Slice,
184+
BlockSlice{<:Block{1}},
185+
BlockSlice{<:BlockRange{1}},
186+
BlockIndices{<:Vector{<:Block{1}}},
184187
}
185188
const BlockIndexRangeSlice = BlockSlice{
186189
<:BlockVector{<:BlockIndex{1},<:Vector{<:BlockIndexRange{1}}}

src/abstractblocksparsearray/abstractblocksparsearray.jl

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,19 @@ function Base.setindex!(
8787
),
8888
)
8989
end
90-
# Custom `_convert` works around the issue that
91-
# `convert(::Type{<:Diagonal}, ::AbstractMatrix)` isnt' defined
92-
# in Julia v1.10 (https://github.com/JuliaLang/julia/pull/48895,
93-
# https://github.com/JuliaLang/julia/pull/52487).
94-
# TODO: Delete once we drop support for Julia v1.10.
95-
aI = @view! a[I...]
96-
aI .= value
90+
if !isconcretetype(blocktype(a))
91+
# Custom `_convert` works around the issue that
92+
# `convert(::Type{<:Diagonal}, ::AbstractMatrix)` isnt' defined
93+
# in Julia v1.10 (https://github.com/JuliaLang/julia/pull/48895,
94+
# https://github.com/JuliaLang/julia/pull/52487).
95+
# TODO: Delete once we drop support for Julia v1.10.
96+
blocks(a)[Int.(I)...] = _convert(blocktype(a), value)
97+
else
98+
# This writes into existing blocks, or constructs blocks
99+
# using the axes.
100+
aI = @view! a[I...]
101+
aI .= value
102+
end
97103
return a
98104
end
99105

src/blocksparsearray/blocksparsearray.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,10 @@ function blocksparse(d::Dict{<:Block,<:AbstractArray}, ax::Tuple)
272272
end
273273
return a
274274
end
275-
function blocksparse(d::Dict{<:Block,<:AbstractArray}, ax::AbstractUnitRange...)
276-
return blocksparse(d, ax)
275+
function blocksparse(
276+
d::Dict{<:Block,<:AbstractArray}, blocklens::AbstractVector{<:Integer}...
277+
)
278+
return blocksparse(d, map(blockedrange, blocklens))
277279
end
278280

279281
# Base `AbstractArray` interface

src/blocksparsearrayinterface/blocksparsearrayinterface.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,11 @@ function SparseArraysBase.getunstoredindex(
537537
return error("Not implemented.")
538538
end
539539

540+
# Convert a blockwise slice on a block sparse array
541+
# to an elementwise slice on the corresponding sparse array
542+
# of blocks.
540543
to_blocks_indices(I::BlockSlice{<:BlockRange{1}}) = Int.(I.block)
544+
to_blocks_indices(I::BlockSlice{<:Block{1}}) = Int(I.block):Int(I.block)
541545
to_blocks_indices(I::BlockIndices{<:Vector{<:Block{1}}}) = Int.(I.blocks)
542546
to_blocks_indices(I::Base.Slice) = Base.OneTo(blocklength(I.indices))
543547

0 commit comments

Comments
 (0)