Skip to content

Commit

Permalink
Update custom show methods
Browse files Browse the repository at this point in the history
  • Loading branch information
brenhinkeller committed Dec 2, 2024
1 parent e9f0f9c commit 0ca34be
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/show.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@

# Custom pretty-printing for York fit results
function Base.show(io::IO, x::YorkFit{T}) where T
if get(io, :compact, false)
print(io, "YorkFit{$T}(…)")
else
Base.show_default(io, x)
end
end
function Base.show(io::IO, ::MIME"text/plain", x::YorkFit{T}) where T
print(io, """YorkFit{$T}:
Least-squares linear fit of the form y = a + bx with
Expand All @@ -10,8 +17,20 @@ function Base.show(io::IO, ::MIME"text/plain", x::YorkFit{T}) where T
)
end

function Base.show(io::IO, x::CI{T}) where T
if get(io, :compact, false)
l = round(x.mean - x.lower, sigdigits=2)
u = round(x.upper - x.mean, sigdigits=2)
nodata = any(isnan, (x.mean, x.upper, x.lower))
d = nodata ? 0 : floor(Int, log10(abs(x.mean))) - floor(Int, log10(max(abs(l),abs(u))))
m = round(x.mean, sigdigits=3+d)
print(io, "$m +$u/-$l")
else
Base.show_default(io, x)
end
end
function Base.show(io::IO, ::MIME"text/plain", x::CI{T}) where T
print(io, """CI{$T} $x
print(io, """CI{$T} $x (95% CI):
mean : $(x.mean)
sigma : $(x.sigma)
median: $(x.median)
Expand Down

0 comments on commit 0ca34be

Please sign in to comment.