|
2 | 2 | using Test: @test, @testset |
3 | 3 | using BlockArrays: |
4 | 4 | AbstractBlockArray, Block, BlockedOneTo, blockedrange, blocklengths, blocksize |
5 | | -using BlockSparseArrays: BlockSparseArray, blockstoredlength |
| 5 | +using BlockSparseArrays: BlockSparseArray, BlockSparseMatrix, blockstoredlength |
6 | 6 | using GradedUnitRanges: |
7 | 7 | GradedUnitRanges, |
8 | 8 | GradedOneTo, |
@@ -318,5 +318,20 @@ const elts = (Float32, Float64, Complex{Float32}, Complex{Float64}) |
318 | 318 | @test Array(a1' * a2) ≈ Array(a1') * Array(a2) |
319 | 319 | @test Array(a1 * a2') ≈ Array(a1) * Array(a2') |
320 | 320 | end |
| 321 | + @testset "Construct from dense" begin |
| 322 | + r = gradedrange([U1(0) => 2, U1(1) => 3]) |
| 323 | + a1 = randn(elt, 2, 2) |
| 324 | + a2 = randn(elt, 3, 3) |
| 325 | + a = cat(a1, a2; dims=(1, 2)) |
| 326 | + b = a[r, dual(r)] |
| 327 | + @test eltype(b) === elt |
| 328 | + @test b isa BlockSpareMatrix{elt} |
| 329 | + @test blockstoredlength(b) == 2 |
| 330 | + @test b[Block(1, 1)] == a1 |
| 331 | + @test iszero(b[Block(2, 1)]) |
| 332 | + @test iszero(b[Block(1, 2)]) |
| 333 | + @test b[Block(2, 2)] == a2 |
| 334 | + @test all(GradedUnitRanges.space_isequal.(axes(b), (r, dual(r)))) |
| 335 | + end |
321 | 336 | end |
322 | 337 | end |
0 commit comments