Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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.2.7"
version = "0.2.8"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ function main()
@test b[Block(1, 2)] == a₁₂

# Matrix multiplication
# TODO: Fix this, broken.
@test_broken b * b ≈ Array(b) * Array(b)
@test b * b ≈ Array(b) * Array(b)

permuted_b = permutedims(b, (2, 1))
@test permuted_b isa BlockSparseArray
Expand Down
3 changes: 1 addition & 2 deletions examples/README.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ function main()
@test b[Block(1, 2)] == a₁₂

## Matrix multiplication
## TODO: Fix this, broken.
@test_broken b * b ≈ Array(b) * Array(b)
@test b * b ≈ Array(b) * Array(b)

permuted_b = permutedims(b, (2, 1))
@test permuted_b isa BlockSparseArray
Expand Down
3 changes: 2 additions & 1 deletion src/blocksparsearrayinterface/blocksparsearrayinterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ end
a::AbstractArray{<:Any,0}, value, I::BlockIndex{0}
)
a_b = blocks(a)[]
a_b[] = value
# `value[]` handles scalars and 0-dimensional arrays.
a_b[] = value[]
# Set the block, required if it is structurally zero.
blocks(a)[] = a_b
return a
Expand Down
6 changes: 4 additions & 2 deletions test/basics/test_basics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ arrayts = (Array, JLArray)
for b in (
(b = copy(a); @allowscalar b[] = 2; b),
(b = copy(a); @allowscalar b[CartesianIndex()] = 2; b),
(b = copy(a); @allowscalar b[CartesianIndex()] = 2; b),
# Regression test for https://github.com/ITensor/BlockSparseArrays.jl/issues/27.
(b = copy(a); @allowscalar b[Block()] = dev(fill(2)); b),
)
@test size(b) == ()
@test isone(length(b))
Expand All @@ -202,8 +205,7 @@ arrayts = (Array, JLArray)
@test @allowscalar(b[CartesianIndex()]) == 2
@test b[Block()] == dev(fill(2))
@test @allowscalar(b[Block()][]) == 2
# Broken:
## @test b[Block()[]] == 2
@test @allowscalar(b[Block()[]]) == 2
end
end

Expand Down
6 changes: 4 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ isexamplefile(fn) =
# tests in groups based on folder structure
for testgroup in filter(isdir, readdir(@__DIR__))
if GROUP == "ALL" || GROUP == uppercase(testgroup)
for file in filter(istestfile, readdir(joinpath(@__DIR__, testgroup); join=true))
groupdir = joinpath(@__DIR__, testgroup)
for file in filter(istestfile, readdir(groupdir))
filename = joinpath(groupdir, file)
@eval @safetestset $file begin
include($file)
include($filename)
end
end
end
Expand Down
Loading