Skip to content

Commit

Permalink
fix _truncate_at_width_or_chars compat usage
Browse files Browse the repository at this point in the history
  • Loading branch information
marius311 committed Oct 6, 2023
1 parent e4607dd commit 1347934
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/chains.jl
Expand Up @@ -124,7 +124,7 @@ function Base.print_array(io::IO, c::Chain; indent=" ")
_,cols = displaysize(io)
for k in keys(c[end])
str = string("$(indent)$(k) => ", repr(c[k]; context=(:limit => true)))
println(io, Base._truncate_at_width_or_chars(str, cols))
println(io, _truncate_at_width_or_chars(str, cols))
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/sampling.jl
Expand Up @@ -431,7 +431,7 @@ function gibbs_sample_slice_θ!(k::Symbol)
@set! θ[k] = θₖ
@set! logpdfθ[k] = logpdfθₖ
@set! Ω.θ = θ
pbar_dict[string(k)] = string_trunc(θₖ)
pbar_dict[string(k)] = _truncate_at_width_or_chars(θₖ)
@pack! state = θ, logpdfθ, Ω
end
end
Expand Down
8 changes: 5 additions & 3 deletions src/util.jl
Expand Up @@ -366,8 +366,7 @@ macro ⌛(args...)
esc(combinedef(sdef))
else
if isnothing(label)
ignore_ANSI = @static VERSION >= v"1.9.0-0" ? true : ()
label = "$(Base._truncate_at_width_or_chars(ignore_ANSI..., string(prewalk(rmlines,ex)),26)) ($source_str)"
label = "$(_truncate_at_width_or_chars(string(prewalk(rmlines,ex)),26)) ($source_str)"
end
:(@timeit $label $(esc(ex)))
end
Expand Down Expand Up @@ -402,7 +401,10 @@ select_known_rule(rule, x, y, R₁::Unknown, R₂::Unknown) = unknown_rule_err



string_trunc(x) = Base._truncate_at_width_or_chars(string(x), displaysize(stdout)[2]-14)
function _truncate_at_width_or_chars(x, width=displaysize(stdout)[2]-14)
ignore_ANSI = @static VERSION >= v"1.9.0-0" ? true : ()
Base._truncate_at_width_or_chars(ignore_ANSI..., string(x), width)
end

import NamedTupleTools
NamedTupleTools.select(d::Dict, keys) = (;(k=>d[k] for k in keys)...)
Expand Down

0 comments on commit 1347934

Please sign in to comment.