From 58fbeadf189d246b62675a4afe3551f1ee0ad668 Mon Sep 17 00:00:00 2001 From: David Widmann Date: Mon, 16 Nov 2020 22:28:11 +0100 Subject: [PATCH] Use `tf_borderless` for PrettyTables >= 0.10 (#251) * Use `tf_borderless` on PrettyTables >= 0.10 * Add tests * Bump version --- Project.toml | 2 +- src/summarize.jl | 8 ++++++-- test/summarize_tests.jl | 6 ++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index 1282df2c..89f4dcf7 100644 --- a/Project.toml +++ b/Project.toml @@ -3,7 +3,7 @@ uuid = "c7f686f2-ff18-58e9-bc7b-31028e88f75d" keywords = ["markov chain monte carlo", "probablistic programming"] license = "MIT" desc = "Chain types and utility functions for MCMC simulations." -version = "4.3.0" +version = "4.3.1" [deps] AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c" diff --git a/src/summarize.jl b/src/summarize.jl index 985ea0d2..13531dc2 100644 --- a/src/summarize.jl +++ b/src/summarize.jl @@ -28,8 +28,12 @@ function Base.show(io::IO, ::MIME"text/plain", df::ChainDataFrame) formatter = PrettyTables.ft_printf("%.$(digits)f") println(io, df.name) - PrettyTables.pretty_table(io, df.nt; - formatters = formatter, tf = PrettyTables.borderless) + # 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, + ) end Base.isequal(c1::ChainDataFrame, c2::ChainDataFrame) = isequal(c1, c2) diff --git a/test/summarize_tests.jl b/test/summarize_tests.jl index e04b6952..6827cb18 100644 --- a/test/summarize_tests.jl +++ b/test/summarize_tests.jl @@ -11,6 +11,12 @@ using Statistics: std parm_df = summarize(chns, sections=[:parameters]) + # check that display of ChainDataFrame does not error + println("compact display:") + show(stdout, parm_df) + println("\nverbose display:") + show(stdout, "text/plain", parm_df) + @test 0.48 < parm_df[:a, :mean][1] < 0.52 @test names(parm_df) == [:parameters, :mean, :std, :naive_se, :mcse, :ess, :rhat]