Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ MCMCDiagnosticTools = "0.3"
MLJModelInterface = "0.3.5, 0.4, 1.0"
NaturalSort = "1"
OrderedCollections = "1.4"
PrettyTables = "0.9, 0.10, 0.11, 0.12, 1, 2"
PrettyTables = "0.9, 0.10, 0.11, 0.12, 1, 2, 3"
Random = "<0.0.1, 1"
RecipesBase = "0.7, 0.8, 1.0"
Statistics = "<0.0.1, 1"
Expand Down
36 changes: 27 additions & 9 deletions src/summarize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,33 @@ end

function Base.show(io::IO, ::MIME"text/plain", df::ChainDataFrame)
digits = get(io, :digits, 4)
formatter = PrettyTables.ft_printf("%.$(digits)f")

println(io, df.name)
# Support for PrettyTables 0.9 (`borderless`) and 0.10 (`tf_borderless`)
PrettyTables.pretty_table(
io, df.nt;
formatters = formatter,
tf = isdefined(PrettyTables, :borderless) ? PrettyTables.borderless : PrettyTables.tf_borderless,
)
if pkgversion(PrettyTables) < v"3.0"
Copy link
Member

@penelopeysm penelopeysm Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if pkgversion(PrettyTables) < v"3.0"
@static if pkgversion(PrettyTables) < v"3.0"

I'm not sure it really makes a difference, but it probably can't hurt.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pkgversion is not supported on Julia < 1.9. IMO the easiest (for the compiler and for maintenance) would be to just require PrettyTables 3 and not introduce any code that is conditional on the loaded PrettyTables version.

formatter = PrettyTables.ft_printf("%.$(digits)f")

println(io, df.name)
# Support for PrettyTables 0.9 (`borderless`) and 0.10 (`tf_borderless`)
PrettyTables.pretty_table(
io, df.nt;
formatters = formatter,
tf = isdefined(PrettyTables, :borderless) ? PrettyTables.borderless : PrettyTables.tf_borderless,
)
else
# v3: ft_printf -> fmt__printf (returns a formatter function)
fmt = PrettyTables.fmt__printf("%.$(digits)f")

println(io, df.name)

# v3: `tf` keyword was replaced by `table_format`
# use the predefined border set "borderless"
PrettyTables.pretty_table(
io, df.nt;
backend = :text, # explicit; :text is the default
formatters = [fmt], # v3 expects a Vector{Function}
table_format = PrettyTables.TextTableFormat(
borders = PrettyTables.text_table_borders__borderless
),
)
end
end

Base.isequal(c1::ChainDataFrame, c2::ChainDataFrame) = isequal(c1, c2)
Expand Down
Loading