-
Notifications
You must be signed in to change notification settings - Fork 419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a compact show
for MvNormal
.
#1786
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention:
... and 133 files with indirect coverage changes 📢 Thoughts on this report? Let us know!. |
@devmotion , I'm not sure who is the right person to ping, sorry. |
Base.show(io::IO, d::MvNormal) = | ||
print(io, "MvNormal($(d.μ), $(d.Σ))") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's already a show_oneline
implementation in Distributions for compact representation. IMO it should actually be the default for show(io, dist)
, and only show(io, ::MIME"text/plain", dist)
should use the current path which returns a one- or multiline representation depending on the number of parameters.
So I wonder what the implications of changing
Line 12 in e407fa5
show(io::IO, d::Distribution) = show(io, d, fieldnames(typeof(d))) |
show(io::IO, d::Distribution) = show_oneline(io, d, fieldnames(typeof(d)))
show(io::IO, ::MIME"text/plain", d::Distribution) = show(io, d, fieldnames(typeof(d)))
would be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
show_oneline
looks messy. Compare the two:
julia> "$dist" # show_oneline
"MvNormal{Bool, PDMats.PDiagMat{Bool, Vector{Bool}}, FillArrays.Falses{1, Tuple{Base.OneTo{Int64}}}}(dim=2, μ=Zeros{Bool}(2), Σ=Bool[1 0; 0 1])"
julia> "$dist" # the new show method
"MvNormal(Zeros{Bool}(2), Bool[1 0; 0 1])"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, maybe the type parameters should be omitted in show_oneline
. Additionally, I don't think you'd want to add the dim
output to MvNormal
, the vanilla show_oneline
with the fields should be sufficient.
Create an
MvNormal
distribution:Before:
After: