Skip to content

Commit 4c466fc

Browse files
authored
replace Base64.stringmime by sprint (#322)
1 parent 56ccada commit 4c466fc

File tree

5 files changed

+33
-35
lines changed

5 files changed

+33
-35
lines changed

Project.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
99

1010
[compat]
1111
Aqua = "0.8"
12-
Base64 = "1.6"
1312
ArrayLayouts = "1.0.8"
1413
Documenter = "0.27"
1514
FillArrays = "1"
@@ -23,7 +22,6 @@ julia = "1.6"
2322

2423
[extras]
2524
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
26-
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
2725
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
2826
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
2927
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
@@ -32,4 +30,4 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
3230
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3331

3432
[targets]
35-
test = ["Aqua", "Base64", "Documenter", "OffsetArrays", "SparseArrays", "StaticArrays", "Test", "Random"]
33+
test = ["Aqua", "Documenter", "OffsetArrays", "SparseArrays", "StaticArrays", "Test", "Random"]

test/test_blockarrayinterface.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using BlockArrays, LinearAlgebra, FillArrays, Base64, Test
1+
using BlockArrays, LinearAlgebra, FillArrays, Test
22

33
# avoid fast-paths for view
44
bview(a, b) = Base.invoke(view, Tuple{AbstractArray,Any}, a, b)
@@ -51,7 +51,7 @@ end
5151
@test H[Block(2, 3)] == A[2:3, 4:6]
5252
@test H[Block(3, 2)] == A[2:3, 4:6]'
5353

54-
@test stringmime("text/plain", UpperTriangular(A)) == "10×10 UpperTriangular{ComplexF64, PseudoBlockMatrix{ComplexF64, Matrix{ComplexF64}, $(typeof(axes(A)))}} with indices 1:1:10×1:1:10:\n 1.0+0.0im │ 11.0+0.0im 21.0+0.0im │ 31.0+0.0im 41.0+0.0im 51.0+0.0im │ 61.0+0.0im 71.0+0.0im 81.0+0.0im 91.0+0.0im\n ───────────┼──────────────────────────┼──────────────────────────────────────┼─────────────────────────────────────────────────\n ⋅ │ 12.0+0.0im 22.0+0.0im │ 32.0+0.0im 42.0+0.0im 52.0+0.0im │ 62.0+0.0im 72.0+0.0im 82.0+0.0im 92.0+0.0im\n ⋅ │ ⋅ 23.0+0.0im │ 33.0+0.0im 43.0+0.0im 53.0+0.0im │ 63.0+0.0im 73.0+0.0im 83.0+0.0im 93.0+0.0im\n ───────────┼──────────────────────────┼──────────────────────────────────────┼─────────────────────────────────────────────────\n ⋅ │ ⋅ ⋅ │ 34.0+0.0im 44.0+0.0im 54.0+0.0im │ 64.0+0.0im 74.0+0.0im 84.0+0.0im 94.0+0.0im\n ⋅ │ ⋅ ⋅ │ ⋅ 45.0+0.0im 55.0+0.0im │ 65.0+0.0im 75.0+0.0im 85.0+0.0im 95.0+0.0im\n ⋅ │ ⋅ ⋅ │ ⋅ ⋅ 56.0+0.0im │ 66.0+0.0im 76.0+0.0im 86.0+0.0im 96.0+0.0im\n ───────────┼──────────────────────────┼──────────────────────────────────────┼─────────────────────────────────────────────────\n ⋅ │ ⋅ ⋅ │ ⋅ ⋅ ⋅ │ 67.0+0.0im 77.0+0.0im 87.0+0.0im 97.0+0.0im\n ⋅ │ ⋅ ⋅ │ ⋅ ⋅ ⋅ │ ⋅ 78.0+0.0im 88.0+0.0im 98.0+0.0im\n ⋅ │ ⋅ ⋅ │ ⋅ ⋅ ⋅ │ ⋅ ⋅ 89.0+0.0im 99.0+0.0im\n ⋅ │ ⋅ ⋅ │ ⋅ ⋅ ⋅ │ ⋅ ⋅ ⋅ 100.0+0.0im"
54+
@test sprint(show, "text/plain", UpperTriangular(A)) == "10×10 UpperTriangular{ComplexF64, PseudoBlockMatrix{ComplexF64, Matrix{ComplexF64}, $(typeof(axes(A)))}} with indices 1:1:10×1:1:10:\n 1.0+0.0im │ 11.0+0.0im 21.0+0.0im │ 31.0+0.0im 41.0+0.0im 51.0+0.0im │ 61.0+0.0im 71.0+0.0im 81.0+0.0im 91.0+0.0im\n ───────────┼──────────────────────────┼──────────────────────────────────────┼─────────────────────────────────────────────────\n ⋅ │ 12.0+0.0im 22.0+0.0im │ 32.0+0.0im 42.0+0.0im 52.0+0.0im │ 62.0+0.0im 72.0+0.0im 82.0+0.0im 92.0+0.0im\n ⋅ │ ⋅ 23.0+0.0im │ 33.0+0.0im 43.0+0.0im 53.0+0.0im │ 63.0+0.0im 73.0+0.0im 83.0+0.0im 93.0+0.0im\n ───────────┼──────────────────────────┼──────────────────────────────────────┼─────────────────────────────────────────────────\n ⋅ │ ⋅ ⋅ │ 34.0+0.0im 44.0+0.0im 54.0+0.0im │ 64.0+0.0im 74.0+0.0im 84.0+0.0im 94.0+0.0im\n ⋅ │ ⋅ ⋅ │ ⋅ 45.0+0.0im 55.0+0.0im │ 65.0+0.0im 75.0+0.0im 85.0+0.0im 95.0+0.0im\n ⋅ │ ⋅ ⋅ │ ⋅ ⋅ 56.0+0.0im │ 66.0+0.0im 76.0+0.0im 86.0+0.0im 96.0+0.0im\n ───────────┼──────────────────────────┼──────────────────────────────────────┼─────────────────────────────────────────────────\n ⋅ │ ⋅ ⋅ │ ⋅ ⋅ ⋅ │ 67.0+0.0im 77.0+0.0im 87.0+0.0im 97.0+0.0im\n ⋅ │ ⋅ ⋅ │ ⋅ ⋅ ⋅ │ ⋅ 78.0+0.0im 88.0+0.0im 98.0+0.0im\n ⋅ │ ⋅ ⋅ │ ⋅ ⋅ ⋅ │ ⋅ ⋅ 89.0+0.0im 99.0+0.0im\n ⋅ │ ⋅ ⋅ │ ⋅ ⋅ ⋅ │ ⋅ ⋅ ⋅ 100.0+0.0im"
5555

5656
V = view(A, Block.(1:2), Block.(1:2))
5757
@test blockisequal(axes(Symmetric(V)), axes(view(A, Block.(1:2), Block.(1:2))))
@@ -130,7 +130,7 @@ end
130130
@test_throws BlockBoundsError A[Block(1, 3)]
131131
@test A == [1 2 0 0; 0 0 1 2]
132132
@test BlockArray(A) == A
133-
@test stringmime("text/plain", A) == "2×2-blocked 2×4 BlockMatrix{$Int, Diagonal{Matrix{$Int}, Vector{Matrix{$Int}}}, Tuple{BlockedUnitRange{Vector{$Int}}, BlockedUnitRange{Vector{$Int}}}}:\n 1 2 │ ⋅ ⋅\n ──────┼──────\n ⋅ ⋅ │ 1 2"
133+
@test sprint(show, "text/plain", A) == "2×2-blocked 2×4 BlockMatrix{$Int, Diagonal{Matrix{$Int}, Vector{Matrix{$Int}}}, Tuple{BlockedUnitRange{Vector{$Int}}, BlockedUnitRange{Vector{$Int}}}}:\n 1 2 │ ⋅ ⋅\n ──────┼──────\n ⋅ ⋅ │ 1 2"
134134

135135
N = 3
136136
D = Diagonal(mortar(Fill.(-(0:N) - (0:N) .^ 2, 1:2:2N+1)))
@@ -187,9 +187,9 @@ end
187187

188188
U = UpperTriangular(Ones((blockedrange([1, 2]), blockedrange([2, 1]))))
189189

190-
@test stringmime("text/plain", A) == "5-element Fill{$Int, 1, Tuple{BlockedUnitRange{Vector{$Int}}}} with indices 1:1:5, with entries equal to 2"
191-
@test stringmime("text/plain", B) == "3×3 Diagonal{Float64, Ones{Float64, 1, Tuple{BlockedUnitRange{Vector{$Int}}}}} with indices 1:1:3×1:1:3"
192-
@test stringmime("text/plain", U) == "3×3 UpperTriangular{Float64, Ones{Float64, 2, Tuple{BlockedUnitRange{Vector{$Int}}, BlockedUnitRange{Vector{$Int}}}}} with indices 1:1:3×1:1:3:\n 1.0 1.0 │ 1.0\n ──────────┼─────\n ⋅ 1.0 │ 1.0\n ⋅ ⋅ │ 1.0"
190+
@test sprint(show, "text/plain", A) == "5-element Fill{$Int, 1, Tuple{BlockedUnitRange{Vector{$Int}}}} with indices 1:1:5, with entries equal to 2"
191+
@test sprint(show, "text/plain", B) == "3×3 Diagonal{Float64, Ones{Float64, 1, Tuple{BlockedUnitRange{Vector{$Int}}}}} with indices 1:1:3×1:1:3"
192+
@test sprint(show, "text/plain", U) == "3×3 UpperTriangular{Float64, Ones{Float64, 2, Tuple{BlockedUnitRange{Vector{$Int}}, BlockedUnitRange{Vector{$Int}}}}} with indices 1:1:3×1:1:3:\n 1.0 1.0 │ 1.0\n ──────────┼─────\n ⋅ 1.0 │ 1.0\n ⋅ ⋅ │ 1.0"
193193

194194
@testset "views" begin
195195
# This in theory can be dropped because `view` returns the block, but we keep in case needed

test/test_blockarrays.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using SparseArrays, BlockArrays, Base64, FillArrays, LinearAlgebra, Test
1+
using SparseArrays, BlockArrays, FillArrays, LinearAlgebra, Test
22
import BlockArrays: _BlockArray
33

44
function test_error_message(f, needle, expected = Exception)
@@ -480,24 +480,24 @@ end
480480
end
481481

482482
@testset "replstring" begin
483-
@test stringmime("text/plain",BlockArray(collect(1:4), [1,3])) == "2-blocked 4-element BlockVector{$Int}:\n 1\n\n 2\n 3\n 4"
484-
@test stringmime("text/plain",PseudoBlockArray(collect(1:4), [1,3])) == "2-blocked 4-element PseudoBlockVector{$Int}:\n 1\n\n 2\n 3\n 4"
485-
@test stringmime("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"
486-
@test stringmime("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"
487-
@test stringmime("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"
488-
@test stringmime("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"
483+
@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"
484+
@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"
485+
@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"
486+
@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"
487+
@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"
488+
@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"
489489
design = zeros(Int16,6,9);
490490
A = BlockArray(design,[6],[4,5])
491-
@test stringmime("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"
491+
@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"
492492
A = PseudoBlockArray(design,[6],[4,5])
493-
@test stringmime("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"
493+
@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"
494494
D = PseudoBlockArray(Diagonal(1:3), [1,2], [2,1])
495-
@test stringmime("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"
495+
@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"
496496

497497
a = BlockArray{Int}(undef_blocks, [1,2])
498-
@test stringmime("text/plain", a) == "2-blocked 3-element BlockVector{Int64}:\n #undef\n ──────\n #undef\n #undef"
498+
@test sprint(show, "text/plain", a) == "2-blocked 3-element BlockVector{Int64}:\n #undef\n ──────\n #undef\n #undef"
499499
B = BlockArray{Int}(undef_blocks, [1,2], [1,1])
500-
@test stringmime("text/plain", B) == "2×2-blocked 3×2 BlockMatrix{Int64}:\n #undef │ #undef\n ────────┼────────\n #undef │ #undef\n #undef │ #undef"
500+
@test sprint(show, "text/plain", B) == "2×2-blocked 3×2 BlockMatrix{Int64}:\n #undef │ #undef\n ────────┼────────\n #undef │ #undef\n #undef │ #undef"
501501
end
502502

503503
@testset "AbstractVector{Int} blocks" begin

test/test_blockindices.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using BlockArrays, FillArrays, Test, Base64, StaticArrays, ArrayLayouts
1+
using BlockArrays, FillArrays, Test, StaticArrays, ArrayLayouts
22
using OffsetArrays
33
import BlockArrays: BlockIndex, BlockIndexRange, BlockSlice
44

@@ -100,16 +100,16 @@ import BlockArrays: BlockIndex, BlockIndexRange, BlockSlice
100100
end
101101

102102
@testset "print" begin
103-
@test stringmime("text/plain", Block()) == "Block()"
104-
@test stringmime("text/plain", Block(1)) == "Block(1)"
105-
@test stringmime("text/plain", Block(1,2)) == "Block(1, 2)"
106-
@test stringmime("text/plain", Block{0}()) == "Block()"
107-
@test stringmime("text/plain", Block{1}(1)) == "Block(1)"
108-
@test stringmime("text/plain", Block{2}(1,2)) == "Block(1, 2)"
103+
@test sprint(show, "text/plain", Block()) == "Block()"
104+
@test sprint(show, "text/plain", Block(1)) == "Block(1)"
105+
@test sprint(show, "text/plain", Block(1,2)) == "Block(1, 2)"
106+
@test sprint(show, "text/plain", Block{0}()) == "Block()"
107+
@test sprint(show, "text/plain", Block{1}(1)) == "Block(1)"
108+
@test sprint(show, "text/plain", Block{2}(1,2)) == "Block(1, 2)"
109109

110-
@test stringmime("text/plain", Block{0,BigInt}()) == "Block{0, BigInt}(())"
111-
@test stringmime("text/plain", Block{1,BigInt}(1)) == "Block{1, BigInt}((1,))"
112-
@test stringmime("text/plain", Block{2}(1,2)) == "Block(1, 2)"
110+
@test sprint(show, "text/plain", Block{0,BigInt}()) == "Block{0, BigInt}(())"
111+
@test sprint(show, "text/plain", Block{1,BigInt}(1)) == "Block{1, BigInt}((1,))"
112+
@test sprint(show, "text/plain", Block{2}(1,2)) == "Block(1, 2)"
113113

114114
@test sprint(show, BlockRange(1:2, 2:3)) == "BlockRange(1:2, 2:3)"
115115
@test sprint(show, "text/plain", BlockRange(1:2, 2:3)) == "BlockRange(1:2, 2:3)"
@@ -314,7 +314,7 @@ end
314314
@test findblock(b,1) == Block(1)
315315
@test_throws BoundsError findblock(b,0)
316316
@test_throws BoundsError findblock(b,6)
317-
@test stringmime("text/plain",blockedrange([1,2,2])) == "3-blocked 5-element BlockedUnitRange{Vector{$Int}}:\n 1\n\n 2\n 3\n\n 4\n 5"
317+
@test sprint(show, "text/plain", blockedrange([1,2,2])) == "3-blocked 5-element BlockedUnitRange{Vector{$Int}}:\n 1\n\n 2\n 3\n\n 4\n 5"
318318
end
319319

320320
@testset "BlockIndex type piracy (#108)" begin

test/test_blockviews.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using BlockArrays, ArrayLayouts, Test, Base64
1+
using BlockArrays, ArrayLayouts, Test
22

33
# useds to force SubArray return
44
bview(a, b) = Base.invoke(view, Tuple{AbstractArray,Any}, a, b)
@@ -193,11 +193,11 @@ bview(a, b) = Base.invoke(view, Tuple{AbstractArray,Any}, a, b)
193193
@test blocks(V) == blocks(A)[1:1,1:2]
194194
@test blocks(W) == blocks(A)[1:2,1:1]
195195
Vi = parentindices(V)
196-
@test stringmime("text/plain", V) == "1×3 view(::BlockMatrix{$Int, Matrix{Matrix{$Int}}, "*
196+
@test sprint(show, "text/plain", V) == "1×3 view(::BlockMatrix{$Int, Matrix{Matrix{$Int}}, "*
197197
"$(typeof(axes(A)))}, $(Vi[1]), $(Vi[2])) "*
198198
"with eltype $Int with indices $(axes(V,1))×$(axes(V,2)):\n 1 │ 2 3"
199199
Wi = parentindices(W)
200-
@test stringmime("text/plain", W) == "3×1 view(::BlockMatrix{$Int, Matrix{Matrix{$Int}}"*
200+
@test sprint(show, "text/plain", W) == "3×1 view(::BlockMatrix{$Int, Matrix{Matrix{$Int}}"*
201201
", $(typeof(axes(A)))}, $(Wi[1]), $(Wi[2])) "*
202202
"with eltype $Int with indices $(axes(W,1))×$(axes(W,2)):\n 1\n\n 4\n 7"
203203
end

0 commit comments

Comments
 (0)