diff --git a/src/krylov_solvers.jl b/src/krylov_solvers.jl index c86ecef2d..2c6b5aa4e 100644 --- a/src/krylov_solvers.jl +++ b/src/krylov_solvers.jl @@ -1886,9 +1886,10 @@ for (KS, fun, nsol, nA, nAt, warm_start) in [ end function ksizeof(attribute) - if isa(attribute, AbstractVector) && !isempty(attribute) + if isa(attribute, Vector{<:AbstractVector}) && !isempty(attribute) + # A vector of vector is a vector of pointers in Julia. # All vectors inside a vector have the same size in Krylov.jl - size_attribute = length(attribute) * ksizeof(attribute[1]) + size_attribute = sizeof(attribute) + length(attribute) * ksizeof(attribute[1]) else size_attribute = sizeof(attribute) end @@ -1938,9 +1939,9 @@ function show(io :: IO, solver :: KrylovSolver{T,FC,S}; show_stats :: Bool=true) field_i = getfield(solver, name_i) size_i = ksizeof(field_i) if (name_i in [:w̅, :w̄, :d̅]) && (VERSION < v"1.8.0-DEV") - Printf.format(io, format2, string(name_i), type_i, format_bytes(size_i)) + (size_i ≠ 0) && Printf.format(io, format2, string(name_i), type_i, format_bytes(size_i)) else - Printf.format(io, format, string(name_i), type_i, format_bytes(size_i)) + (size_i ≠ 0) && Printf.format(io, format, string(name_i), type_i, format_bytes(size_i)) end end @printf(io, "└%s┴%s┴%s┘\n","─"^l1,"─"^l2,"─"^l3) diff --git a/test/test_solvers.jl b/test/test_solvers.jl index 8c1e2975d..2c98dc795 100644 --- a/test/test_solvers.jl +++ b/test/test_solvers.jl @@ -142,6 +142,9 @@ function test_solvers(FC) @test mapreduce(x -> length(x) - mapreduce(y -> occursin(y, x), |, ["w̅","w̄","d̅"]) == len_col1, &, str2[1:3:end-2]) @test mapreduce(x -> length(x) - mapreduce(y -> occursin(y, x), |, ["w̅","w̄","d̅"]) == len_col2, &, str2[2:3:end-1]) @test mapreduce(x -> length(x) - mapreduce(y -> occursin(y, x), |, ["w̅","w̄","d̅"]) == len_col3, &, str2[3:3:end]) + + # Code coverage + show(io, solver, show_stats=true) end end end