Skip to content

Commit 748c108

Browse files
committed
Do not print leading newline in _show_with_braille_patterns
1 parent 0ea6ee9 commit 748c108

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

stdlib/SparseArrays/src/sparsematrix.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ function _show_with_braille_patterns(io::IOContext, S::AbstractSparseMatrixCSC)
271271
brailleGrid[k, l] |= brailleBlocks[p]
272272
end
273273
end
274-
println(io)
275274
foreach(c -> print(io, Char(c)), @view brailleGrid[1:end-1])
276275
end
277276

@@ -282,6 +281,7 @@ function Base.show(io::IOContext, S::AbstractSparseMatrixCSC)
282281
Base.print_matrix(ioc, S)
283282
return
284283
end
284+
println(io)
285285
_show_with_braille_patterns(io, S)
286286
end
287287

stdlib/SparseArrays/test/sparse.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,37 +2232,37 @@ end
22322232
show(io, MIME"text/plain"(), A)
22332233
@test String(take!(io)) == "1×2 SparseArrays.SparseMatrixCSC{Float64,Int64} with 2 stored entries:\n 1.0 2.0"
22342234
_show_with_braille_patterns(convert(IOContext, io), A)
2235-
@test String(take!(io)) == "\n"
2235+
@test String(take!(io)) == ""
22362236

22372237
# every 1-dot braille pattern
22382238
for (i, b) in enumerate(split("⠁⠂⠄⡀⠈⠐⠠⢀", ""))
22392239
A = spzeros(Int64, Int64, 4, 2)
22402240
A[i] = 1
22412241
_show_with_braille_patterns(convert(IOContext, io), A)
2242-
@test String(take!(io)) == "\n" * b
2242+
@test String(take!(io)) == b
22432243
end
22442244

22452245
# empty braille pattern Char(10240)
22462246
A = spzeros(Int64, Int64, 4, 2)
22472247
_show_with_braille_patterns(convert(IOContext, io), A)
2248-
@test String(take!(io)) == "\n" * Char(10240)
2248+
@test String(take!(io)) == "" * Char(10240)
22492249

22502250
A = sparse(Int64[1, 2, 4, 2, 3], Int64[1, 1, 1, 2, 2], Int64[1, 1, 1, 1, 1], 4, 2)
22512251
show(io, MIME"text/plain"(), A)
22522252
@test String(take!(io)) == "4×2 SparseArrays.SparseMatrixCSC{Int64,Int64} with 5 stored entries:\n 1 ⋅\n 1 1\n ⋅ 1\n 1 ⋅"
22532253
_show_with_braille_patterns(convert(IOContext, io), A)
2254-
@test String(take!(io)) == "\n"
2254+
@test String(take!(io)) == ""
22552255

22562256
A = sparse(Int64[1, 3, 2, 4], Int64[1, 1, 2, 2], Int64[1, 1, 1, 1], 7, 3)
22572257
show(io, MIME"text/plain"(), A)
22582258
@test String(take!(io)) == "7×3 SparseArrays.SparseMatrixCSC{Int64,Int64} with 4 stored entries:\n 1 ⋅ ⋅\n ⋅ 1 ⋅\n 1 ⋅ ⋅\n ⋅ 1 ⋅\n ⋅ ⋅ ⋅\n ⋅ ⋅ ⋅\n ⋅ ⋅ ⋅"
22592259
_show_with_braille_patterns(convert(IOContext, io), A)
2260-
@test String(take!(io)) == "\n" * Char(10240) * "\n" * Char(10240)^2
2260+
@test String(take!(io)) == "" * Char(10240) * "\n" * Char(10240)^2
22612261

22622262
A = sparse(Int64[1:10;], Int64[1:10;], fill(Float64(1), 10))
22632263
_show_with_braille_patterns(convert(IOContext, io), A)
22642264
brailleString = "⠑⢄" * Char(10240)^3 * "\n" * Char(10240)^2 * "⠑⢄" * Char(10240) * "\n" * Char(10240)^4 * ""
2265-
@test String(take!(io)) == "\n" * brailleString
2265+
@test String(take!(io)) == brailleString
22662266

22672267
function _filled_sparse(m::Integer, n::Integer)
22682268
C = CartesianIndices((m, n))[:]
@@ -2274,18 +2274,18 @@ end
22742274
# vertical scaling
22752275
ioc = IOContext(io, :displaysize => (5, 80), :limit => true)
22762276
_show_with_braille_patterns(ioc, _filled_sparse(10, 10))
2277-
@test String(take!(io)) == "\n" * "⣿⣿"
2277+
@test String(take!(io)) == "⣿⣿"
22782278

22792279
_show_with_braille_patterns(ioc, _filled_sparse(20, 10))
2280-
@test String(take!(io)) == "\n" * ""
2280+
@test String(take!(io)) == ""
22812281

22822282
# horizontal scaling
22832283
ioc = IOContext(io, :displaysize => (80, 4), :limit => true)
22842284
_show_with_braille_patterns(ioc, _filled_sparse(8, 8))
2285-
@test String(take!(io)) == "\n" * "⣿⣿"
2285+
@test String(take!(io)) == "⣿⣿"
22862286

22872287
_show_with_braille_patterns(ioc, _filled_sparse(8, 16))
2288-
@test String(take!(io)) == "\n" * "⠛⠛"
2288+
@test String(take!(io)) == "⠛⠛"
22892289
end
22902290

22912291
@testset "check buffers" for n in 1:3

0 commit comments

Comments
 (0)