71
71
@test Matrix (ret) == zeros (6 ,6 )
72
72
73
73
A = [1 ,2 ,3 ,4 ,5 ,6 ]
74
- @test A == BlockArray (A, 1 : 3 ) == BlockArray {Int} (A, 1 : 3 ) ==
74
+ @test A == BlockArray (A, 1 : 3 ) == BlockArray {Int} (A, 1 : 3 ) ==
75
75
BlockArray (A, (blockedrange (1 : 3 ),)) == BlockArray {Int} (A, (blockedrange (1 : 3 ),)) ==
76
76
BlockArray {Float64} (A, 1 : 3 )
77
77
end
91
91
92
92
A = [1 ,2 ,3 ,4 ,5 ,6 ]
93
93
@test_throws BoundsError PseudoBlockArray (A,10 : 20 )
94
- @test A == PseudoBlockArray (A, 1 : 3 ) == PseudoBlockArray {Int} (A, 1 : 3 ) ==
94
+ @test A == PseudoBlockArray (A, 1 : 3 ) == PseudoBlockArray {Int} (A, 1 : 3 ) ==
95
95
PseudoBlockArray (A, (blockedrange (1 : 3 ),)) == PseudoBlockArray {Int} (A, (blockedrange (1 : 3 ),)) ==
96
96
PseudoBlockArray {Float64} (A, 1 : 3 )
97
97
end
151
151
)
152
152
end
153
153
end
154
-
154
+
155
155
@testset " BlockVector" begin
156
156
a_data = [1 ,2 ,3 ]
157
157
a = BlockVector (a_data,[1 ,2 ])
@@ -196,29 +196,29 @@ end
196
196
B = BlockArray (I, fill (2 ,4 ), fill (2 ,5 ))
197
197
@test B isa BlockMatrix{Bool}
198
198
@test B == BlockMatrix (I, fill (2 ,4 ), fill (2 ,5 )) ==
199
- BlockArray (I, blockedrange .((fill (2 ,4 ), fill (2 ,5 )))) ==
200
- BlockMatrix (I, blockedrange .((fill (2 ,4 ), fill (2 ,5 )))) ==
199
+ BlockArray (I, blockedrange .((fill (2 ,4 ), fill (2 ,5 )))) ==
200
+ BlockMatrix (I, blockedrange .((fill (2 ,4 ), fill (2 ,5 )))) ==
201
201
Matrix (I, 8 , 10 )
202
-
202
+
203
203
B = BlockArray {Float64} (I, fill (2 ,4 ), fill (2 ,5 ))
204
204
@test B isa BlockMatrix{Float64}
205
205
@test B == BlockMatrix {Float64} (I, fill (2 ,4 ), fill (2 ,5 )) ==
206
- BlockArray {Float64} (I, blockedrange .((fill (2 ,4 ), fill (2 ,5 )))) ==
207
- BlockMatrix {Float64} (I, blockedrange .((fill (2 ,4 ), fill (2 ,5 )))) ==
206
+ BlockArray {Float64} (I, blockedrange .((fill (2 ,4 ), fill (2 ,5 )))) ==
207
+ BlockMatrix {Float64} (I, blockedrange .((fill (2 ,4 ), fill (2 ,5 )))) ==
208
208
Matrix (I, 8 , 10 )
209
209
210
210
B = PseudoBlockArray (I, fill (2 ,4 ), fill (2 ,5 ))
211
211
@test B isa PseudoBlockMatrix{Bool}
212
212
@test B == PseudoBlockMatrix (I, fill (2 ,4 ), fill (2 ,5 )) ==
213
- PseudoBlockArray (I, blockedrange .((fill (2 ,4 ), fill (2 ,5 )))) ==
214
- PseudoBlockMatrix (I, blockedrange .((fill (2 ,4 ), fill (2 ,5 )))) ==
213
+ PseudoBlockArray (I, blockedrange .((fill (2 ,4 ), fill (2 ,5 )))) ==
214
+ PseudoBlockMatrix (I, blockedrange .((fill (2 ,4 ), fill (2 ,5 )))) ==
215
215
Matrix (I, 8 , 10 )
216
-
216
+
217
217
B = PseudoBlockArray {Float64} (I, fill (2 ,4 ), fill (2 ,5 ))
218
218
@test B isa PseudoBlockMatrix{Float64}
219
219
@test B == PseudoBlockMatrix {Float64} (I, fill (2 ,4 ), fill (2 ,5 )) ==
220
- PseudoBlockArray {Float64} (I, blockedrange .((fill (2 ,4 ), fill (2 ,5 )))) ==
221
- PseudoBlockMatrix {Float64} (I, blockedrange .((fill (2 ,4 ), fill (2 ,5 )))) ==
220
+ PseudoBlockArray {Float64} (I, blockedrange .((fill (2 ,4 ), fill (2 ,5 )))) ==
221
+ PseudoBlockMatrix {Float64} (I, blockedrange .((fill (2 ,4 ), fill (2 ,5 )))) ==
222
222
Matrix (I, 8 , 10 )
223
223
end
224
224
end
352
352
353
353
à = PseudoBlockArray (rand (2 ,3 ), Fill (1 ,2 ), [2 ,1 ])
354
354
@test convert (typeof (A), Ã) == Ã
355
-
355
+
356
356
@test PseudoBlockArray (A, axes (Ã)) isa typeof (Ã)
357
- @test PseudoBlockArray (A, axes (Ã)) == A
357
+ @test PseudoBlockArray (A, axes (Ã)) == A
358
358
359
359
360
360
A = BlockArray (rand (2 ,3 ), [1 ,1 ], [2 ,1 ])
381
381
buf = IOBuffer ()
382
382
Base. showerror (buf, BlockBoundsError (A, (3 ,2 )))
383
383
@test String (take! (buf)) == " BlockBoundsError: attempt to access 2×2-blocked 4×5 BlockMatrix{Float64, Matrix{Matrix{Float64}}, Tuple{BlockedUnitRange{Vector{$Int }}, BlockedUnitRange{Vector{$Int }}}} at block index [3,2]"
384
-
384
+
385
385
386
386
A = PseudoBlockArray (rand (4 , 5 ), [1 ,3 ], [2 ,3 ]);
387
387
Base. showerror (buf, BlockBoundsError (A, (3 ,2 )))
522
522
b = randn (6 )
523
523
@test A* b isa PseudoBlockVector{Float64}
524
524
@test Ã* b isa PseudoBlockVector{Float64}
525
- @test A* b ≈ Ã* b ≈ Matrix (A)* b
525
+ @test A* b ≈ Ã* b ≈ Matrix (A)* b
526
526
end
527
527
528
528
@testset " Blockindex" begin
532
532
A = PseudoBlockArray (randn (3 ,3 ), [1 ,2 ], [1 ,2 ])
533
533
@test A[Block (1 )[1 ], Block (1 )[1 ]] == A[Block (1 ,1 )[1 ,1 ]] == A[1 ,1 ]
534
534
@test A[Block (1 )[1 : 1 ], Block (1 )[1 : 1 ]] == A[Block (1 ,1 )[1 : 1 ,1 : 1 ]] == A[1 : 1 ,1 : 1 ]
535
- @test A[Block (1 )[1 : 1 ], Block (1 )[1 ]] == BlockArray (A)[Block (1 )[1 : 1 ], Block (1 )[1 ]] == A[1 : 1 ,1 ]
536
- @test A[Block (1 )[1 ], Block (1 )[1 : 1 ]] == BlockArray (A)[Block (1 )[1 ], Block (1 )[1 : 1 ]] == A[1 ,1 : 1 ]
535
+ @test A[Block (1 )[1 : 1 ], Block (1 )[1 ]] == BlockArray (A)[Block (1 )[1 : 1 ], Block (1 )[1 ]] == A[1 : 1 ,1 ]
536
+ @test A[Block (1 )[1 ], Block (1 )[1 : 1 ]] == BlockArray (A)[Block (1 )[1 ], Block (1 )[1 : 1 ]] == A[1 ,1 : 1 ]
537
537
end
538
538
539
539
@testset " permutedims" begin
560
560
A = BlockVector {Float64} (undef,Int[])
561
561
@test @inferred (isempty (blocklengths (axes (A,1 ))))
562
562
end
563
- end
563
+
564
+ @testset " pretty-printing" begin
565
+ v = Zeros (3 )
566
+ m = mortar ([v])
567
+ io = IOBuffer ()
568
+ Base. print_array (io, m)
569
+ s1 = String (take! (io))
570
+ Base. print_array (io, v)
571
+ s2 = String (take! (io))
572
+ @test s1 == s2
573
+
574
+ d = Diagonal (Ones (2 ,2 ))
575
+ m = mortar (reshape ([d], 1 , 1 ))
576
+ Base. print_array (io, m)
577
+ s1 = String (take! (io))
578
+ Base. print_array (io, d)
579
+ s2 = String (take! (io))
580
+ @test s1 == s2
581
+ end
582
+ end
0 commit comments