I am printing a struct with PrettyTables.jl and would like boolean values to print out as true or false rather than Float64s. Is there a way to do this? Thank you.
Example
using PrettyTables
struct M
x::String
y::Float64
z::Bool
end
function Base.show(io::IO, ::MIME"text/plain", m::M)
values = [getfield(m, f) for f in fieldnames(M)]
return pretty_table(
values;
compact_printing=false,
header=["Value"],
row_name_alignment=:l,
row_names=[fieldnames(M)...],
formatters=ft_printf("%5.2f"),
alignment=:l,
)
end
m = M("x", .3, true)
Output:
julia> m
┌───┬───────┐
│ │ Value │
├───┼───────┤
│ x │ x │
│ y │ 0.30 │
│ z │ 1.00 │
└───┴───────┘