Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "BlockSparseArrays"
uuid = "2c9a651f-6452-4ace-a6ac-809f4280fbb4"
authors = ["ITensor developers <[email protected]> and contributors"]
version = "0.3.0"
version = "0.3.1"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
19 changes: 15 additions & 4 deletions src/abstractblocksparsearray/wrappedabstractblocksparsearray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,22 @@
end

function SparseArraysBase.isstored(
A::AnyAbstractBlockSparseArray{<:Any,N}, I::Vararg{Int,N}
a::AnyAbstractBlockSparseArray{<:Any,N}, I::Vararg{Int,N}
) where {N}
bI = BlockIndex(findblockindex.(axes(A), I))
bA = blocks(A)
return isstored(bA, bI.I...) && isstored(bA[bI.I...], bI.α...)
bI = BlockIndex(findblockindex.(axes(a), I))
blocks_a = blocks(a)
return isstored(blocks_a, bI.I...) && isstored(blocks_a[bI.I...], bI.α...)

Check warning on line 345 in src/abstractblocksparsearray/wrappedabstractblocksparsearray.jl

View check run for this annotation

Codecov / codecov/patch

src/abstractblocksparsearray/wrappedabstractblocksparsearray.jl#L343-L345

Added lines #L343 - L345 were not covered by tests
end

# This circumvents issues passing certain kinds of SubArrays
# to the more generic block sparse `isstored` definition,
# for example `blocks(a)` is broken for certain slices.
# TODO: Fix those issues and delete this in favor of using the generic
# version.
function SparseArraysBase.isstored(

Check warning on line 353 in src/abstractblocksparsearray/wrappedabstractblocksparsearray.jl

View check run for this annotation

Codecov / codecov/patch

src/abstractblocksparsearray/wrappedabstractblocksparsearray.jl#L353

Added line #L353 was not covered by tests
a::SubArray{<:Any,N,<:AbstractBlockSparseArray}, I::Vararg{Int,N}
) where {N}
return isstored(parent(a), Base.reindex(parentindices(a), I)...)

Check warning on line 356 in src/abstractblocksparsearray/wrappedabstractblocksparsearray.jl

View check run for this annotation

Codecov / codecov/patch

src/abstractblocksparsearray/wrappedabstractblocksparsearray.jl#L356

Added line #L356 was not covered by tests
end

function Base.replace_in_print_matrix(
Expand Down
6 changes: 6 additions & 0 deletions test/test_basics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1148,10 +1148,16 @@ arrayts = (Array, JLArray)
if elt === Float64
# Not testing other element types since they change the
# spacing so it isn't easy to make the test general.

a = BlockSparseMatrix{elt,arrayt{elt,2}}(undef, [2, 2], [2, 2])
@allowscalar a[1, 2] = 12
@test sprint(show, "text/plain", a) ==
"$(summary(a)):\n $(zero(eltype(a))) $(eltype(a)(12)) │ ⋅ ⋅ \n $(zero(eltype(a))) $(zero(eltype(a))) │ ⋅ ⋅ \n ───────────┼──────────\n ⋅ ⋅ │ ⋅ ⋅ \n ⋅ ⋅ │ ⋅ ⋅ "

a = BlockSparseArray{elt,3,arrayt{elt,3}}(undef, [2, 2], [2, 2], [2, 2])
@allowscalar a[1, 2, 1] = 121
@test sprint(show, "text/plain", a) ==
"$(summary(a)):\n[:, :, 1] =\n $(zero(eltype(a))) $(eltype(a)(121)) ⋅ ⋅ \n $(zero(eltype(a))) $(zero(eltype(a))) ⋅ ⋅ \n ⋅ ⋅ ⋅ ⋅ \n ⋅ ⋅ ⋅ ⋅ \n\n[:, :, 2] =\n $(zero(eltype(a))) $(zero(eltype(a))) ⋅ ⋅ \n $(zero(eltype(a))) $(zero(eltype(a))) ⋅ ⋅ \n ⋅ ⋅ ⋅ ⋅ \n ⋅ ⋅ ⋅ ⋅ \n\n[:, :, 3] =\n ⋅ ⋅ ⋅ ⋅ \n ⋅ ⋅ ⋅ ⋅ \n ⋅ ⋅ ⋅ ⋅ \n ⋅ ⋅ ⋅ ⋅ \n\n[:, :, 4] =\n ⋅ ⋅ ⋅ ⋅ \n ⋅ ⋅ ⋅ ⋅ \n ⋅ ⋅ ⋅ ⋅ \n ⋅ ⋅ ⋅ ⋅ "
end
end
@testset "TypeParameterAccessors.position" begin
Expand Down
Loading