Skip to content

Commit 5e7647d

Browse files
committed
fix doctests
1 parent 1afabba commit 5e7647d

6 files changed

Lines changed: 32 additions & 28 deletions

File tree

docs/src/index.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,11 @@ julia> I = [1, 4, 3, 5]; J = [4, 7, 18, 9]; V = [1, 2, -5, 3];
113113
114114
julia> S = sparse(I,J,V)
115115
5×18 SparseMatrixCSC{Int64, Int64} with 4 stored entries:
116-
⎡⠀⠈⠀⠀⠀⠀⠀⠀⢀⎤
117-
⎣⠀⠀⠀⠂⡀⠀⠀⠀⠀⎦
116+
⋅ ⋅ ⋅ 1 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
117+
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
118+
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ -5
119+
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 2 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
120+
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 3 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
118121
119122
julia> R = sparsevec(I,V)
120123
5-element SparseVector{Int64, Int64} with 4 stored entries:

src/linalg.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,19 +2094,19 @@ julia> A[4:4:8] .= 1;
20942094
20952095
julia> A
20962096
3×3 SparseMatrixCSC{Float64, Int64} with 2 stored entries:
2097-
1.0 ⋅
2098-
⋅ 1.0
2099-
⋅ ⋅
2097+
1.0 ⋅
2098+
⋅ 1.0
2099+
⋅ ⋅
21002100
21012101
julia> C = spzeros(3,3);
21022102
21032103
julia> C[2:4:6] .= 2;
21042104
21052105
julia> C
21062106
3×3 SparseMatrixCSC{Float64, Int64} with 2 stored entries:
2107-
⋅ ⋅
2108-
2.0 ⋅
2109-
⋅ 2.0
2107+
⋅ ⋅ ⋅
2108+
2.0 ⋅ ⋅
2109+
⋅ 2.0 ⋅
21102110
21112111
julia> SparseArrays.mergeinds!(C, A)
21122112
3×3 SparseMatrixCSC{Float64, Int64} with 4 stored entries:

src/solvers/spqr.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ Q factor:
192192
4×4 SparseArrays.SPQR.QRSparseQ{Float64, Int64}
193193
R factor:
194194
2×2 SparseMatrixCSC{Float64, Int64} with 2 stored entries:
195-
-1.41421 ⋅
196-
-1.41421
195+
-1.41421
196+
-1.41421
197197
Row permutation:
198198
4-element Vector{Int64}:
199199
1
@@ -471,10 +471,10 @@ when the problem is underdetermined.
471471
```jldoctest
472472
julia> A = sparse([1,2,4], [1,1,1], [1.0,1.0,1.0], 4, 2)
473473
4×2 SparseMatrixCSC{Float64, Int64} with 3 stored entries:
474-
1.0
475-
1.0
476-
477-
1.0
474+
1.0 ⋅
475+
1.0 ⋅
476+
⋅ ⋅
477+
1.0 ⋅
478478
479479
julia> qr(A)\\fill(1.0, 4)
480480
2-element Vector{Float64}:

src/sparsematrix.jl

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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
19551956
julia> dropzeros(A)
19561957
3×3 SparseMatrixCSC{Float64, Int64} with 2 stored entries:
1957-
1.0
1958-
1959-
1.0
1958+
1.0
1959+
1960+
1.0
19601961
```
19611962
"""
19621963
dropzeros(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))
21272128
julia> sprandn(2, 2, 0.75)
21282129
2×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
21542155
julia> spzeros(3, 3)
21552156
3×3 SparseMatrixCSC{Float64, Int64} with 0 stored entries:
2156-
2157-
2158-
2157+
2158+
2159+
21592160
21602161
julia> spzeros(Float32, 4)
21612162
4-element SparseVector{Float32, Int64} with 0 stored entries

test/issues.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -758,14 +758,14 @@ let
758758
B = similar(A, T12960)
759759
@test repr(B) == "sparse([1, 2, 3], [1, 2, 3], $T12960[#undef, #undef, #undef], 3, 3)"
760760
@test occursin(
761-
"\n #undef \n #undef \n #undef",
761+
" #undef ⋅ \n ⋅ #undef \n #undef",
762762
repr(MIME("text/plain"), B),
763763
)
764764

765765
B[1,2] = T12960()
766766
@test repr(B) == "sparse([1, 1, 2, 3], [1, 2, 2, 3], $T12960[#undef, $T12960(), #undef, #undef], 3, 3)"
767767
@test occursin(
768-
"\n #undef T12960() \n #undef \n #undef",
768+
"\n #undef T12960() \n ⋅ #undef \n #undef",
769769
repr(MIME("text/plain"), B),
770770
)
771771
end

test/sparsematrix_constructors_indexing.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,9 +1514,9 @@ end
15141514
A = spzeros(Float32, Int64, 2, 2)
15151515
for (transform, showstring) in zip(
15161516
(identity, adjoint, transpose), (
1517-
"2×2 $SparseMatrixCSC{Float32, Int64} with 0 stored entries:\n \n ",
1518-
"2×2 $Adjoint{Float32, $SparseMatrixCSC{Float32, Int64}} with 0 stored entries:\n \n ",
1519-
"2×2 $Transpose{Float32, $SparseMatrixCSC{Float32, Int64}} with 0 stored entries:\n \n ",
1517+
"2×2 $SparseMatrixCSC{Float32, Int64} with 0 stored entries:\n\n",
1518+
"2×2 $Adjoint{Float32, $SparseMatrixCSC{Float32, Int64}} with 0 stored entries:\n\n",
1519+
"2×2 $Transpose{Float32, $SparseMatrixCSC{Float32, Int64}} with 0 stored entries:\n\n",
15201520
))
15211521
show(io, MIME"text/plain"(), transform(A))
15221522
@test String(take!(io)) == showstring

0 commit comments

Comments
 (0)