From b040b35b7075cd8c14a221c8ecaed1e26f5f700f Mon Sep 17 00:00:00 2001 From: "Bernd@MyMac" Date: Fri, 14 Nov 2025 07:38:20 +0100 Subject: [PATCH 1/3] Bump PrettyTables compat to v3 (related to #540 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 87c5a74f..03439e0d 100644 --- a/Project.toml +++ b/Project.toml @@ -23,6 +23,6 @@ Reexport = "1" Statistics = "1" Tables = "1" julia = "1.6" -PrettyTables = "2" +PrettyTables = "3" IteratorInterfaceExtensions = "1" TableTraits = "1" From 3d41aa0b22b1e49cd9d48a33b9de40d851a9e4e4 Mon Sep 17 00:00:00 2001 From: "Bernd@MyMac" Date: Fri, 14 Nov 2025 08:20:32 +0100 Subject: [PATCH 2/3] Adapt to v3 of PrettyTables.jl --- src/timearray.jl | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/timearray.jl b/src/timearray.jl index d0d3032d..ec4a7a8b 100644 --- a/src/timearray.jl +++ b/src/timearray.jl @@ -246,28 +246,20 @@ function Base.show( println(io) - if allcols && allrows - crop = :none - elseif allcols - crop = :vertical - elseif allrows - crop = :horizontal - else - crop = :both - end - data = hcat(timestamp(ta), values(ta)) header = vcat("", string.(colnames(ta))) return pretty_table( io, data; - header=header, - newline_at_end=false, + column_labels=header, + new_line_at_end=false, reserved_display_lines=2, - row_label_alignment=:r, - header_alignment=:l, - crop=crop, - vcrop_mode=:middle, + row_label_column_alignment=:r, + column_label_alignment=:l, + continuation_row_alignment=:c, + fit_table_in_display_horizontally=!allcols, # replaced crop keyword for v3 of PrettyTables + fit_table_in_display_vertically=!allrows, # replaced crop keyword for v3 of PrettyTables + vertical_crop_mode=:middle, ) end From fd8ccadbe37e9f78970ca402b527dc0666b4b219 Mon Sep 17 00:00:00 2001 From: "Bernd@MyMac" Date: Fri, 14 Nov 2025 08:39:04 +0100 Subject: [PATCH 3/3] Allow backwards compatibility to PrettyTables v2 --- Project.toml | 2 +- src/TimeSeries.jl | 2 +- src/timearray.jl | 103 +++++++++++++++++++++++++++++++++------------- 3 files changed, 76 insertions(+), 31 deletions(-) diff --git a/Project.toml b/Project.toml index 03439e0d..24204dcb 100644 --- a/Project.toml +++ b/Project.toml @@ -23,6 +23,6 @@ Reexport = "1" Statistics = "1" Tables = "1" julia = "1.6" -PrettyTables = "3" +PrettyTables = "2,3" IteratorInterfaceExtensions = "1" TableTraits = "1" diff --git a/src/TimeSeries.jl b/src/TimeSeries.jl index e4f911bf..254cd04d 100644 --- a/src/TimeSeries.jl +++ b/src/TimeSeries.jl @@ -9,7 +9,7 @@ using DocStringExtensions: SIGNATURES using RecipesBase using Reexport using Tables -using PrettyTables: pretty_table +using PrettyTables: PrettyTables, pretty_table export TimeArray, AbstractTimeSeries, diff --git a/src/timearray.jl b/src/timearray.jl index ec4a7a8b..351b44ca 100644 --- a/src/timearray.jl +++ b/src/timearray.jl @@ -230,37 +230,82 @@ function Base.show(io::IO, ta::TimeArray) return nothing end end -function Base.show( - io::IO, - ::MIME"text/plain", - ta::TimeArray; - allrows=!get(io, :limit, false), - allcols=!get(io, :limit, false), -) - nrow = size(values(ta), 1) - ncol = size(values(ta), 2) - show(io, ta) # summary line - - nrow == 0 && return nothing - - println(io) - - data = hcat(timestamp(ta), values(ta)) - header = vcat("", string.(colnames(ta))) - return pretty_table( - io, - data; - column_labels=header, - new_line_at_end=false, - reserved_display_lines=2, - row_label_column_alignment=:r, - column_label_alignment=:l, - continuation_row_alignment=:c, - fit_table_in_display_horizontally=!allcols, # replaced crop keyword for v3 of PrettyTables - fit_table_in_display_vertically=!allrows, # replaced crop keyword for v3 of PrettyTables - vertical_crop_mode=:middle, +@static if pkgversion(PrettyTables).major == 2 + # TODO: When PrettyTables v2 is more widely spread get rid off this and the compat + function Base.show( + io::IO, + ::MIME"text/plain", + ta::TimeArray; + allrows=!get(io, :limit, false), + allcols=!get(io, :limit, false), ) + nrow = size(values(ta), 1) + ncol = size(values(ta), 2) + + show(io, ta) # summary line + + nrow == 0 && return nothing + + println(io) + + if allcols && allrows + crop = :none + elseif allcols + crop = :vertical + elseif allrows + crop = :horizontal + else + crop = :both + end + + data = hcat(timestamp(ta), values(ta)) + header = vcat("", string.(colnames(ta))) + return pretty_table( + io, + data; + header=header, + newline_at_end=false, + reserved_display_lines=2, + row_label_alignment=:r, + header_alignment=:l, + crop=crop, + vcrop_mode=:middle, + ) + end +else + function Base.show( + io::IO, + ::MIME"text/plain", + ta::TimeArray; + allrows=!get(io, :limit, false), + allcols=!get(io, :limit, false), + ) + nrow = size(values(ta), 1) + ncol = size(values(ta), 2) + + show(io, ta) # summary line + + nrow == 0 && return nothing + + println(io) + + data = hcat(timestamp(ta), values(ta)) + header = vcat("", string.(colnames(ta))) + return pretty_table( + io, + data; + column_labels=header, + new_line_at_end=false, + reserved_display_lines=2, + row_label_column_alignment=:r, + column_label_alignment=:l, + continuation_row_alignment=:c, + fit_table_in_display_horizontally=!allcols, # replaced crop keyword for v3 of PrettyTables + fit_table_in_display_vertically=!allrows, # replaced crop keyword for v3 of PrettyTables + vertical_crop_mode=:middle, + ) + end end ###### getindex #################