|
| 1 | +module TestBlockArrays |
| 2 | + |
1 | 3 | using SparseArrays, BlockArrays, FillArrays, LinearAlgebra, Test, OffsetArrays
|
2 | 4 | import BlockArrays: _BlockArray
|
3 | 5 |
|
@@ -545,24 +547,30 @@ end
|
545 | 547 | end
|
546 | 548 |
|
547 | 549 | @testset "replstring" begin
|
548 |
| - @test sprint(show, "text/plain", BlockArray(collect(1:4), [1,3])) == "2-blocked 4-element BlockVector{$Int}:\n 1\n ─\n 2\n 3\n 4" |
549 |
| - @test sprint(show, "text/plain", PseudoBlockArray(collect(1:4), [1,3])) == "2-blocked 4-element PseudoBlockVector{$Int}:\n 1\n ─\n 2\n 3\n 4" |
550 |
| - @test sprint(show, "text/plain", BlockArray(collect(reshape(1:16, 4, 4)), [1,3], [2,2])) == "2×2-blocked 4×4 BlockMatrix{$Int}:\n 1 5 │ 9 13\n ──────┼────────\n 2 6 │ 10 14\n 3 7 │ 11 15\n 4 8 │ 12 16" |
551 |
| - @test sprint(show, "text/plain", PseudoBlockArray(collect(reshape(1:16, 4, 4)), [1,3], [2,2])) == "2×2-blocked 4×4 PseudoBlockMatrix{$Int}:\n 1 5 │ 9 13\n ──────┼────────\n 2 6 │ 10 14\n 3 7 │ 11 15\n 4 8 │ 12 16" |
552 |
| - @test sprint(show, "text/plain", BlockArray(collect(reshape(1:8, 2, 2, 2)), [1,1], [1,1], [1,1])) == "2×2×2-blocked 2×2×2 BlockArray{$Int, 3}:\n[:, :, 1] =\n 1 3\n 2 4\n\n[:, :, 2] =\n 5 7\n 6 8" |
553 |
| - @test sprint(show, "text/plain", PseudoBlockArray(collect(reshape(1:8, 2, 2, 2)), [1,1], [1,1], [1,1])) == "2×2×2-blocked 2×2×2 PseudoBlockArray{$Int, 3}:\n[:, :, 1] =\n 1 3\n 2 4\n\n[:, :, 2] =\n 5 7\n 6 8" |
| 550 | + A = BlockArray(collect(1:4), [1,3]) |
| 551 | + @test sprint(show, "text/plain", A) == "$(summary(A)):\n 1\n ─\n 2\n 3\n 4" |
| 552 | + A = PseudoBlockArray(collect(1:4), [1,3]) |
| 553 | + @test sprint(show, "text/plain", A) == "$(summary(A)):\n 1\n ─\n 2\n 3\n 4" |
| 554 | + A = BlockArray(collect(reshape(1:16, 4, 4)), [1,3], [2,2]) |
| 555 | + @test sprint(show, "text/plain", A) == "$(summary(A)):\n 1 5 │ 9 13\n ──────┼────────\n 2 6 │ 10 14\n 3 7 │ 11 15\n 4 8 │ 12 16" |
| 556 | + A = PseudoBlockArray(collect(reshape(1:16, 4, 4)), [1,3], [2,2]) |
| 557 | + @test sprint(show, "text/plain", A) == "$(summary(A)):\n 1 5 │ 9 13\n ──────┼────────\n 2 6 │ 10 14\n 3 7 │ 11 15\n 4 8 │ 12 16" |
| 558 | + A = BlockArray(collect(reshape(1:8, 2, 2, 2)), [1,1], [1,1], [1,1]) |
| 559 | + @test sprint(show, "text/plain", A) == "$(summary(A)):\n[:, :, 1] =\n 1 3\n 2 4\n\n[:, :, 2] =\n 5 7\n 6 8" |
| 560 | + A = PseudoBlockArray(collect(reshape(1:8, 2, 2, 2)), [1,1], [1,1], [1,1]) |
| 561 | + @test sprint(show, "text/plain", A) == "$(summary(A)):\n[:, :, 1] =\n 1 3\n 2 4\n\n[:, :, 2] =\n 5 7\n 6 8" |
554 | 562 | design = zeros(Int16,6,9);
|
555 | 563 | A = BlockArray(design,[6],[4,5])
|
556 |
| - @test sprint(show, "text/plain", A) == "1×2-blocked 6×9 BlockMatrix{Int16}:\n 0 0 0 0 │ 0 0 0 0 0\n 0 0 0 0 │ 0 0 0 0 0\n 0 0 0 0 │ 0 0 0 0 0\n 0 0 0 0 │ 0 0 0 0 0\n 0 0 0 0 │ 0 0 0 0 0\n 0 0 0 0 │ 0 0 0 0 0" |
| 564 | + @test sprint(show, "text/plain", A) == "$(summary(A)):\n 0 0 0 0 │ 0 0 0 0 0\n 0 0 0 0 │ 0 0 0 0 0\n 0 0 0 0 │ 0 0 0 0 0\n 0 0 0 0 │ 0 0 0 0 0\n 0 0 0 0 │ 0 0 0 0 0\n 0 0 0 0 │ 0 0 0 0 0" |
557 | 565 | A = PseudoBlockArray(design,[6],[4,5])
|
558 |
| - @test sprint(show, "text/plain", A) == "1×2-blocked 6×9 PseudoBlockMatrix{Int16}:\n 0 0 0 0 │ 0 0 0 0 0\n 0 0 0 0 │ 0 0 0 0 0\n 0 0 0 0 │ 0 0 0 0 0\n 0 0 0 0 │ 0 0 0 0 0\n 0 0 0 0 │ 0 0 0 0 0\n 0 0 0 0 │ 0 0 0 0 0" |
| 566 | + @test sprint(show, "text/plain", A) == "$(summary(A)):\n 0 0 0 0 │ 0 0 0 0 0\n 0 0 0 0 │ 0 0 0 0 0\n 0 0 0 0 │ 0 0 0 0 0\n 0 0 0 0 │ 0 0 0 0 0\n 0 0 0 0 │ 0 0 0 0 0\n 0 0 0 0 │ 0 0 0 0 0" |
559 | 567 | D = PseudoBlockArray(Diagonal(1:3), [1,2], [2,1])
|
560 |
| - @test sprint(show, "text/plain", D) == "2×2-blocked 3×3 $(PseudoBlockMatrix{Int, Diagonal{Int, UnitRange{Int}}, Tuple{BlockedUnitRange{Vector{Int}}, BlockedUnitRange{Vector{Int}}}}):\n 1 ⋅ │ ⋅\n ──────┼───\n ⋅ 2 │ ⋅\n ⋅ ⋅ │ 3" |
| 568 | + @test sprint(show, "text/plain", D) == "$(summary(D)):\n 1 ⋅ │ ⋅\n ──────┼───\n ⋅ 2 │ ⋅\n ⋅ ⋅ │ 3" |
561 | 569 |
|
562 | 570 | a = BlockArray{Int}(undef_blocks, [1,2])
|
563 |
| - @test sprint(show, "text/plain", a) == "2-blocked 3-element BlockVector{Int64}:\n #undef\n ──────\n #undef\n #undef" |
| 571 | + @test sprint(show, "text/plain", a) == "$(summary(a)):\n #undef\n ──────\n #undef\n #undef" |
564 | 572 | B = BlockArray{Int}(undef_blocks, [1,2], [1,1])
|
565 |
| - @test sprint(show, "text/plain", B) == "2×2-blocked 3×2 BlockMatrix{Int64}:\n #undef │ #undef\n ────────┼────────\n #undef │ #undef\n #undef │ #undef" |
| 573 | + @test sprint(show, "text/plain", B) == "$(summary(B)):\n #undef │ #undef\n ────────┼────────\n #undef │ #undef\n #undef │ #undef" |
566 | 574 | end
|
567 | 575 |
|
568 | 576 | @testset "AbstractVector{Int} blocks" begin
|
|
781 | 789 | @test size(a[:,1]) == (8,)
|
782 | 790 | end
|
783 | 791 | end
|
| 792 | + |
| 793 | +end # module |
0 commit comments