Skip to content

Commit 261c876

Browse files
authored
add backwards compatibility (#211)
1 parent 3013fb5 commit 261c876

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ MLUtils = "0.4.8"
5858
Makie = "0.22, 0.23, 0.24"
5959
NCDatasets = "0.14.8"
6060
OptimizationOptimisers = "0.3.7"
61-
PrettyTables = "3.1.2"
61+
PrettyTables = "2.4.0, 3.1.2"
6262
ProgressMeter = "1.10.4"
6363
Reexport = "1.2.2"
6464
Static = "1.3.1"

src/utils/show_generic.jl

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,29 @@ end
6868

6969
function Base.show(io::IO, ::MIME"text/plain", pc::ParameterContainer)
7070
table = pc.table
71-
return PrettyTables.pretty_table(
72-
io, table;
73-
column_labels = collect(keys(table.axes[2])),
74-
row_labels = collect(keys(table.axes[1])),
75-
alignment = :r,
76-
)
71+
72+
col_labels = collect(keys(table.axes[2]))
73+
row_labels = collect(keys(table.axes[1]))
74+
75+
return @static if isdefined(PrettyTables, :PrintingSpec)
76+
# PrettyTables v3+
77+
PrettyTables.pretty_table(
78+
io,
79+
table;
80+
column_labels = col_labels,
81+
row_labels = row_labels,
82+
alignment = :r,
83+
)
84+
else
85+
# PrettyTables v2
86+
PrettyTables.pretty_table(
87+
io,
88+
table;
89+
header = col_labels,
90+
row_labels = row_labels,
91+
alignment = :r,
92+
)
93+
end
7794
end
7895

7996
# compact show for nested usage

0 commit comments

Comments
 (0)