@@ -511,7 +511,7 @@ function _show_with_dotted_zeros(io::IO, S::AbstractSparseMatrixCSCInclAdjointAn
511511 rows, cols, vals = rowvals (parent (S)), ColumnIndices (parent (S)), nonzeros (parent (S))
512512 (S isa Adjoint) | (S isa Transpose) && ((rows, cols) = (cols, rows))
513513
514- align = [alignment (io, val) for val in vals]
514+ align = [isassigned (vals, val) ? alignment (io, vals[ val]) : ( 3 , 3 ) for val in eachindex ( vals) ]
515515 colwidths = [max .((0 , 0 ), align[findall (== (col), cols)]. .. ) for col in axes (S,2 )]
516516 displaysize (io)[2 ] < sum (sum .(colwidths) .+ 2 ) && return _show_with_braille_patterns (io, S)
517517
@@ -531,7 +531,8 @@ function _show_with_dotted_zeros(io::IO, S::AbstractSparseMatrixCSCInclAdjointAn
531531 print (io, " " ^ l * " ⋅" * (col== axes (S,2 )[end ] ? " " : " " ^ r))
532532 else
533533 l, r = (l+ 1 , r+ 1 ) .- align[index][]
534- print (io, " " ^ l, vals[index][], (col== axes (S,2 )[end ] ? " " : " " ^ r))
534+ out = isassigned (vals, index[]) ? vals[index][] : " #undef"
535+ print (io, " " ^ l, out, (col== axes (S,2 )[end ] ? " " : " " ^ r))
535536 end
536537 end
537538 row == axes (S,1 )[end ] || println (io)
@@ -1954,9 +1955,9 @@ julia> A = sparse([1, 2, 3], [1, 2, 3], [1.0, 0.0, 1.0])
19541955
19551956julia> dropzeros(A)
195619573×3 SparseMatrixCSC{Float64, Int64} with 2 stored entries:
1957- 1.0 ⋅ ⋅
1958- ⋅ ⋅ ⋅
1959- ⋅ ⋅ 1.0
1958+ 1.0 ⋅ ⋅
1959+ ⋅ ⋅ ⋅
1960+ ⋅ ⋅ 1.0
19601961```
19611962"""
19621963dropzeros (A:: AbstractSparseMatrixCSC ) = dropzeros! (copy (A))
@@ -2126,7 +2127,7 @@ argument specifies a random number generator, see [Random Numbers](@ref).
21262127```jldoctest; setup = :(using Random; Random.seed!(0))
21272128julia> sprandn(2, 2, 0.75)
212821292×2 SparseMatrixCSC{Float64, Int64} with 3 stored entries:
2129- -1.20577 ⋅
2130+ -1.20577 ⋅
21302131 0.311817 -0.234641
21312132```
21322133"""
@@ -2153,9 +2154,9 @@ specified.
21532154```jldoctest
21542155julia> spzeros(3, 3)
215521563×3 SparseMatrixCSC{Float64, Int64} with 0 stored entries:
2156- ⋅ ⋅ ⋅
2157- ⋅ ⋅ ⋅
2158- ⋅ ⋅ ⋅
2157+ ⋅ ⋅ ⋅
2158+ ⋅ ⋅ ⋅
2159+ ⋅ ⋅ ⋅
21592160
21602161julia> spzeros(Float32, 4)
216121624-element SparseVector{Float32, Int64} with 0 stored entries
0 commit comments