Skip to content

Commit

Permalink
pretty printing for InitialGuess
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasKoziorek committed Oct 3, 2024
1 parent 4e41fdc commit fb07cd0
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/pretty_printing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,29 @@ function Base.show(io::IO, ::MIME"text/plain", po::PeriodicOrbit)
for (desc, val) in descriptors
println(io, rpad(" $(desc): ", padlen), val)
end
end

function Base.summary(ig::InitialGuess)
digits = 5
u0 = round.(ig.u0, digits=digits)
T = isnothing(ig.T) ? "nothing" : round(ig.T, digits=ig_round_digits)
return "$(typeof(ig))($(u0), $(T))"
end

function Base.show(io::IO, ig::InitialGuess)
print(io, summary(ig))
end

function Base.show(io::IO, ::MIME"text/plain", ig::InitialGuess)
digits = 5
descriptors = [
"u0" => round.(ig.u0, digits=digits),
"T" => isnothing(ig.T) ? "nothing" : round(ig.T, digits=digits)
]
padlen = maximum(length(d[1]) for d in descriptors) + 3

println(io, typeof(ig))
for (desc, val) in descriptors
println(io, rpad(" $(desc): ", padlen), val)
end
end

0 comments on commit fb07cd0

Please sign in to comment.