Skip to content

Commit

Permalink
Interpolate SparseVector in display test (#455)
Browse files Browse the repository at this point in the history
interpolate SparseVector in display test
  • Loading branch information
jishnub authored Oct 12, 2023
1 parent d884072 commit 0f8bbda
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions test/sparsevector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1559,24 +1559,24 @@ mutable struct t20488 end
@testset "show" begin
io = IOBuffer()
show(io, MIME"text/plain"(), sparsevec(Int64[1], [1.0]))
@test String(take!(io)) == "1-element $(SparseArrays.SparseVector){Float64, Int64} with 1 stored entry:\n [1] = 1.0"
@test String(take!(io)) == "1-element $SparseVector{Float64, Int64} with 1 stored entry:\n [1] = 1.0"
show(io, MIME"text/plain"(), spzeros(Float64, Int64, 2))
@test String(take!(io)) == "2-element $(SparseArrays.SparseVector){Float64, Int64} with 0 stored entries"
@test String(take!(io)) == "2-element $SparseVector{Float64, Int64} with 0 stored entries"
show(io, similar(sparsevec(rand(3) .+ 0.1), t20488))
@test String(take!(io)) == "sparsevec([1, 2, 3], $t20488[#undef, #undef, #undef], 3)"
show(io, MIME"text/plain"(), similar(sparsevec(rand(3) .+ 0.1), t20488))
@test String(take!(io)) == "3-element SparseVector{$t20488, $Int} with 3 stored entries:\n [1] = #undef\n [2] = #undef\n [3] = #undef"
@test String(take!(io)) == "3-element $SparseVector{$t20488, $Int} with 3 stored entries:\n [1] = #undef\n [2] = #undef\n [3] = #undef"
# Test that we don't introduce unnecessary padding for long sparse arrays
show(io, MIME"text/plain"(), SparseVector(div(typemax(Int32), 2), Int32[1], Int32[1]))
@test String(take!(io)) == "1073741823-element $(SparseArrays.SparseVector){Int32, Int32} with 1 stored entry:\n [1] = 1"
@test String(take!(io)) == "1073741823-element $SparseVector{Int32, Int32} with 1 stored entry:\n [1] = 1"
# ensure that :limit=>true leads to truncation
show(IOContext(io, :limit=>true), MIME"text/plain"(), sparsevec([1:20;], [1:20;]))
@test contains(String(take!(io)), "\n \u22ee\n")

# ensure that a vector of sparsevecs doesn't use pretty printing for elements
S = sparsevec(Int64[1,4], Int64[2,3])
@test repr(S) == "sparsevec($(Int64[1,4]), $(Int64[2,3]), 4)"
@test repr([S]) == "$(SparseArrays.SparseVector){Int64, Int64}[$(repr(S))]"
@test repr([S]) == "$SparseVector{Int64, Int64}[$(repr(S))]"
end

@testset "spzeros with index type" begin
Expand Down

0 comments on commit 0f8bbda

Please sign in to comment.