Skip to content

Commit e42a5ed

Browse files
committed
Fix 0-dim isstored
1 parent 3a9aa2d commit e42a5ed

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

src/blocksparsearrayinterface/blocksparsearrayinterface.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ function eachblockstoredindex(a::AbstractArray)
4242
return Block.(Tuple.(eachstoredindex(blocks(a))))
4343
end
4444

45-
function SparseArraysBase.isstored(
46-
a::AbstractArray{<:Any,N}, I::Vararg{Block{1},N}
47-
) where {N}
45+
function SparseArraysBase.isstored(a::AbstractArray, I1::Block{1}, Irest::Block{1}...)
46+
I = (I1, Irest...)
4847
return isstored(blocks(a), Int.(I)...)
4948
end
5049
function SparseArraysBase.isstored(a::AbstractArray{<:Any,N}, I::Block{N}) where {N}

test/test_view_bang.jl

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,22 @@ arrayts = (Array, JLArray)
5555
@test view!(a, blk...) == x
5656
@test @view!(a[blk...]) == x
5757
end
58-
## # 0-dim case
59-
## # Regression test for https://github.com/ITensor/BlockSparseArrays.jl/issues/148
60-
## for I in ((), (Block(),))
61-
## a = dev(BlockSparseArray{elt}(undef))
62-
## @test !isstored(a)
63-
## @test iszero(blockstoredlength(a))
64-
## @test isempty(eachblockstoredindex(a))
65-
## @test iszero(a)
66-
## b = @view! a[I...]
67-
## @test isstored(a)
68-
## @test isone(blockstoredlength(a))
69-
## @test issetequal(eachblockstoredindex(a), [Block()])
70-
## @test iszero(adapt(Array)(a))
71-
## @test b isa arrayt{elt,0}
72-
## @test size(b) == ()
73-
## # Converting to `Array` works around a bug in `iszero(JLArray{Float64}(undef))`.
74-
## @test iszero(adapt(Array)(b))
75-
## end
58+
# 0-dim case
59+
# Regression test for https://github.com/ITensor/BlockSparseArrays.jl/issues/148
60+
for I in ((), (Block(),))
61+
a = dev(BlockSparseArray{elt}(undef))
62+
@test !isstored(a)
63+
@test iszero(blockstoredlength(a))
64+
@test isempty(eachblockstoredindex(a))
65+
@test iszero(a)
66+
b = @view! a[I...]
67+
@test isstored(a)
68+
@test isone(blockstoredlength(a))
69+
@test issetequal(eachblockstoredindex(a), [Block()])
70+
@test iszero(adapt(Array)(a))
71+
@test b isa arrayt{elt,0}
72+
@test size(b) == ()
73+
# Converting to `Array` works around a bug in `iszero(JLArray{Float64}(undef))`.
74+
@test iszero(adapt(Array)(b))
75+
end
7676
end

0 commit comments

Comments
 (0)