@@ -360,7 +360,7 @@ function Base.show(io::IO, ::MIME"text/plain", S::AbstractSparseMatrixCSCInclAdj
360360 show_circular (io, S) && return
361361 io = IOContext (io, :compact => true , :typeinfo => eltype (S), :SHOWN_SET => S)
362362
363- if (screen[1 ] < size (S, 1 ) + 4 ) | (screen[2 ] < 3 size (S, 2 ))
363+ if (screen[1 ] < size (S, 1 ) + 5 ) | (screen[2 ] < 3 size (S, 2 ))
364364 _show_with_braille_patterns (io, S)
365365 else
366366 _show_with_dotted_zeros (io, S)
410410
411411const brailleBlocks = UInt16[' ⠁' , ' ⠂' , ' ⠄' , ' ⡀' , ' ⠈' , ' ⠐' , ' ⠠' , ' ⢀' ]
412412function _show_with_braille_patterns (io:: IO , S:: AbstractSparseMatrixCSCInclAdjointAndTranspose )
413- try
414- zero (eltype (S))
415- catch
416- printstyled (io, " WARNING: could not find generic zero for given elements. expect errors and wrong results\n " , color= :red )
417- end
418-
419413 m, n = size (S)
420414 (m == 0 || n == 0 ) && return show (io, MIME (" text/plain" ), S)
421415
@@ -424,6 +418,13 @@ function _show_with_braille_patterns(io::IO, S::AbstractSparseMatrixCSCInclAdjoi
424418 maxHeight = displaysize (io)[1 ] - 4 # -4 from [Prompt, header, newline after elements, new prompt]
425419 maxWidth = displaysize (io)[2 ] - 2 # -2 from brackets
426420
421+ try
422+ zero (eltype (S))
423+ catch
424+ printstyled (stderr , " WARNING: could not find generic zero for given elements. expect errors and wrong results\n " , color= :red )
425+ maxHeight = maxHeight - 1
426+ end
427+
427428 # In the process of generating the braille pattern to display the nonzero
428429 # structure of `S`, we need to be able to scale the matrix `S` to a
429430 # smaller matrix with the same aspect ratio as `S`, but fits on the
@@ -511,14 +512,14 @@ function _show_with_dotted_zeros(io::IO, S::AbstractSparseMatrixCSCInclAdjointAn
511512 rows, cols, vals = rowvals (parent (S)), ColumnIndices (parent (S)), nonzeros (parent (S))
512513 (S isa Adjoint) | (S isa Transpose) && ((rows, cols) = (cols, rows))
513514
514- align = [alignment (io, val) for val in vals]
515+ align = [isassigned (vals, val) ? alignment (io, vals[ val]) : ( 3 , 3 ) for val in eachindex ( vals) ]
515516 colwidths = [max .((0 , 0 ), align[findall (== (col), cols)]. .. ) for col in axes (S,2 )]
516517 displaysize (io)[2 ] < sum (sum .(colwidths) .+ 2 ) && return _show_with_braille_patterns (io, S)
517518
518519 try
519520 zero (eltype (S))
520521 catch
521- printstyled (io , " WARNING: could not find generic zero for given elements. expect errors and wrong results\n " , color= :red )
522+ printstyled (stderr , " WARNING: could not find generic zero for given elements. expect errors and wrong results\n " , color= :red )
522523 end
523524
524525 for row in axes (S,1 )
@@ -531,7 +532,9 @@ function _show_with_dotted_zeros(io::IO, S::AbstractSparseMatrixCSCInclAdjointAn
531532 print (io, " " ^ l * " ⋅" * (col== axes (S,2 )[end ] ? " " : " " ^ r))
532533 else
533534 l, r = (l+ 1 , r+ 1 ) .- align[index][]
534- print (io, " " ^ l, vals[index][], (col== axes (S,2 )[end ] ? " " : " " ^ r))
535+ print (io, " " ^ l)
536+ show (io, isassigned (vals, index[]) ? vals[index][] : " #undef" )
537+ col == axes (S,2 )[end ] || print (io, " " ^ r)
535538 end
536539 end
537540 row == axes (S,1 )[end ] || println (io)
@@ -1954,9 +1957,9 @@ julia> A = sparse([1, 2, 3], [1, 2, 3], [1.0, 0.0, 1.0])
19541957
19551958julia> dropzeros(A)
195619593×3 SparseMatrixCSC{Float64, Int64} with 2 stored entries:
1957- 1.0 ⋅ ⋅
1958- ⋅ ⋅ ⋅
1959- ⋅ ⋅ 1.0
1960+ 1.0 ⋅ ⋅
1961+ ⋅ ⋅ ⋅
1962+ ⋅ ⋅ 1.0
19601963```
19611964"""
19621965dropzeros (A:: AbstractSparseMatrixCSC ) = dropzeros! (copy (A))
@@ -2126,7 +2129,7 @@ argument specifies a random number generator, see [Random Numbers](@ref).
21262129```jldoctest; setup = :(using Random; Random.seed!(0))
21272130julia> sprandn(2, 2, 0.75)
212821312×2 SparseMatrixCSC{Float64, Int64} with 3 stored entries:
2129- -1.20577 ⋅
2132+ -1.20577 ⋅
21302133 0.311817 -0.234641
21312134```
21322135"""
@@ -2153,9 +2156,9 @@ specified.
21532156```jldoctest
21542157julia> spzeros(3, 3)
215521583×3 SparseMatrixCSC{Float64, Int64} with 0 stored entries:
2156- ⋅ ⋅ ⋅
2157- ⋅ ⋅ ⋅
2158- ⋅ ⋅ ⋅
2159+ ⋅ ⋅ ⋅
2160+ ⋅ ⋅ ⋅
2161+ ⋅ ⋅ ⋅
21592162
21602163julia> spzeros(Float32, 4)
216121644-element SparseVector{Float32, Int64} with 0 stored entries
0 commit comments