PrettyPrint.jl
PrettyPrint.jl copied to clipboard
Prettier structs?
A lot of this is likely personal preference, but I thought I'd share some thoughts on what would make the printing of structs easier to read IMHO:
- Add a space before and after the equals sign.
- Each field on its own line.
- Always indent fields 2 spaces (first field starts on a new line).
- Put the closing parenthesis on a separate line.
Current output:
julia> pprint(r)
NamedTuple{(:pnl, :pnl1, :pnl2, :p1, :p2), Tuple{Float64, Float64, Float64, Params2, Params2}}(
pnl=0.32214519260980023,
pnl1=0.51126703754539,
pnl2=-0.1891218449355898,
p1=Params2(entry_decay=0.21716672940921328,
entry_trigger_high=0.00014128907148849498,
entry_trigger_low=0.019990643867276083,
vol_decay=0.01, vol_trigger_high=0.000366458513092389,
vol_trigger_low=0.000366458513092389),
p2=Params2(entry_decay=0.032722034246227806,
entry_trigger_high=1.1894259645369238e-5,
entry_trigger_low=0.00014128907148849498,
vol_decay=0.01, vol_trigger_high=8.892624233407248e-5,
vol_trigger_low=7.026301452349746e-5),
)
Propose output:
julia> pprint(r)
NamedTuple{(:pnl, :pnl1, :pnl2, :p1, :p2), Tuple{Float64, Float64, Float64, Params2, Params2}}(
pnl = 0.32214519260980023,
pnl1 = 0.51126703754539,
pnl2 = -0.1891218449355898,
p1 = Params2(
entry_decay = 0.21716672940921328,
entry_trigger_high = 0.00014128907148849498,
entry_trigger_low = 0.019990643867276083,
vol_decay = 0.01,
vol_trigger_high = 0.000366458513092389,
vol_trigger_low = 0.000366458513092389
),
p2 = Params2(
entry_decay = 0.032722034246227806,
entry_trigger_high = 1.1894259645369238e-5,
entry_trigger_low = 0.00014128907148849498,
vol_decay = 0.01,
vol_trigger_high = 8.892624233407248e-5,
vol_trigger_low = 7.026301452349746e-5
),
)