@@ -39,7 +39,8 @@ using BlockSparseArrays:
39
39
using GPUArraysCore: @allowscalar
40
40
using JLArrays: JLArray, JLMatrix
41
41
using LinearAlgebra: Adjoint, Transpose, dot, norm, tr
42
- using SparseArraysBase: SparseArrayDOK, SparseMatrixDOK, SparseVectorDOK, storedlength
42
+ using SparseArraysBase:
43
+ SparseArrayDOK, SparseMatrixDOK, SparseVectorDOK, isstored, storedlength
43
44
using Test: @test , @test_broken , @test_throws , @testset , @inferred
44
45
using TestExtras: @constinferred
45
46
using TypeParameterAccessors: TypeParameterAccessors, Position
@@ -1159,6 +1160,24 @@ arrayts = (Array, JLArray)
1159
1160
@test view! (a, blk... ) == x
1160
1161
@test @view! (a[blk... ]) == x
1161
1162
end
1163
+ # 0-dim case
1164
+ # Regression test for https://github.com/ITensor/BlockSparseArrays.jl/issues/148
1165
+ for I in ((), (Block (),))
1166
+ a = dev (BlockSparseArray {elt} (undef))
1167
+ @test ! isstored (a)
1168
+ @test iszero (blockstoredlength (a))
1169
+ @test isempty (eachblockstoredindex (a))
1170
+ @test iszero (a)
1171
+ b = @view! a[I... ]
1172
+ @test isstored (a)
1173
+ @test isone (blockstoredlength (a))
1174
+ @test issetequal (eachblockstoredindex (a), [Block ()])
1175
+ @test iszero (adapt (Array)(a))
1176
+ @test b isa arrayt{elt,0 }
1177
+ @test size (b) == ()
1178
+ # Converting to `Array` works around a bug in `iszero(JLArray{Float64}(undef))`.
1179
+ @test iszero (adapt (Array)(b))
1180
+ end
1162
1181
end
1163
1182
@testset " LinearAlgebra" begin
1164
1183
a1 = dev (BlockSparseArray {elt} (undef, [2 , 3 ], [2 , 3 ]))
0 commit comments