diff --git a/src/chains.jl b/src/chains.jl index 9583fec5..0fee7e9e 100644 --- a/src/chains.jl +++ b/src/chains.jl @@ -324,7 +324,7 @@ function header(c::AbstractChains; section=missing) # Return header. return string( - # "Log model evidence = $(c.logevidence)\n", #FIXME: Uncomment. + "Log evidence = $(c.logevidence)\n", "Iterations = $(first(c)):$(last(c))\n", "Thinning interval = $(step(c))\n", "Chains = $(join(map(string, chains(c)), ", "))\n", diff --git a/test/demo-plot.png b/test/demo-plot.png deleted file mode 100644 index 154e0c1e..00000000 Binary files a/test/demo-plot.png and /dev/null differ diff --git a/test/plot_test.jl b/test/plot_test.jl index 37460981..283e0480 100644 --- a/test/plot_test.jl +++ b/test/plot_test.jl @@ -53,4 +53,6 @@ chn = Chains(val) p_subset_colordim = plot(chn, 2, colordim = :parameter) @test isa(p_subset_colordim, Plots.Plot) + + rm("demo-plot.png") end diff --git a/test/sections_test.txt b/test/sections_test.txt deleted file mode 100644 index 086ec014..00000000 --- a/test/sections_test.txt +++ /dev/null @@ -1,70 +0,0 @@ -Iterations = 1:100 -Thinning interval = 1 -Chains = Chain1, Chain2, Chain3, Chain4 -Samples per chain = 100 -parameters = sigma, mu - -Empirical Posterior Estimates: -============================================= -parameters - Mean SD Naive SE MCSE ESS - mu 2200.5 1007.9052 50.3953 580.9475 3.01 -sigma 2100.5 1007.9052 50.3953 580.9475 3.01 - -Quantiles: -============================================= -parameters - 2.5% 25.0% 50.0% 75.0% 97.5% - mu 801 1500.75 2200.5 2900.25 3600 -sigma 701 1400.75 2100.5 2800.25 3500 - -Iterations = 1:100 -Thinning interval = 1 -Chains = Chain1, Chain2, Chain3, Chain4 -Samples per chain = 100 -internals = lp__, accept_stat__, stepsize__, treedepth__, n_leapfrog__, divergent__, energy__ - -Empirical Posterior Estimates: -===================================================== -internals - Mean SD Naive SE MCSE ESS -accept_stat__ 1500.5 1007.9052 50.3953 580.9475 3.01 - divergent__ 1900.5 1007.9052 50.3953 580.9475 3.01 - energy__ 2000.5 1007.9052 50.3953 580.9475 3.01 - lp__ 1400.5 1007.9052 50.3953 580.9475 3.01 - n_leapfrog__ 1800.5 1007.9052 50.3953 580.9475 3.01 - stepsize__ 1600.5 1007.9052 50.3953 580.9475 3.01 - treedepth__ 1700.5 1007.9052 50.3953 580.9475 3.01 - -Quantiles: -===================================================== -internals - 2.5% 25.0% 50.0% 75.0% 97.5% -accept_stat__ 101 800.75 1500.5 2200.25 2900 - divergent__ 501 1200.75 1900.5 2600.25 3300 - energy__ 601 1300.75 2000.5 2700.25 3400 - lp__ 1 700.75 1400.5 2100.25 2800 - n_leapfrog__ 401 1100.75 1800.5 2500.25 3200 - stepsize__ 201 900.75 1600.5 2300.25 3000 - treedepth__ 301 1000.75 1700.5 2400.25 3100 - -Iterations = 1:100 -Thinning interval = 1 -Chains = Chain1, Chain2, Chain3, Chain4 -Samples per chain = 100 -parameters = sigma, mu - -Empirical Posterior Estimates: -============================================= -parameters - Mean SD Naive SE MCSE ESS - mu 2200.5 1007.9052 50.3953 580.9475 3.01 -sigma 2100.5 1007.9052 50.3953 580.9475 3.01 - -Quantiles: -============================================= -parameters - 2.5% 25.0% 50.0% 75.0% 97.5% - mu 801 1500.75 2200.5 2900.25 3600 -sigma 701 1400.75 2100.5 2800.25 3500 - diff --git a/test/sections_tests.jl b/test/sections_tests.jl index df41214e..407f272f 100644 --- a/test/sections_tests.jl +++ b/test/sections_tests.jl @@ -1,34 +1,45 @@ using MCMCChains, Test @testset "describe sections" begin - - a3d = reshape(1:3600, 100, 9, 4) - - cnames = ["lp__" , "accept_stat__", "stepsize__" , "treedepth__" , - "n_leapfrog__" , "divergent__" , "energy__", "sigma", "mu" ] - - pi = filter(p -> length(p) > 2 && p[end-1:end] == "__", cnames) - p = filter(p -> !(p in pi), cnames) - - c = Chains(a3d, - Symbol.(cnames), - Dict( - :parameters => Symbol.(p), - :internals => Symbol.(pi) - ) - ) - - tmpdir = tempdir() - open(joinpath(tmpdir, "sections_test.txt"), "w") do io - describe(io, c, section=:parameters); - describe(io, c, section=:internals); - describe(io, c); - end - - - @test open(f->read(f, String), joinpath(tmpdir, "sections_test.txt")) == - open(f->read(f, String), joinpath(@__DIR__, "sections_test.txt")) - - #println(open(f->read(f, String), joinpath(tmpdir, "sections_test.txt"))) - + + a3d = reshape(1:3600, 100, 9, 4) + + cnames = ["lp__" , "accept_stat__", "stepsize__" , "treedepth__" , + "n_leapfrog__" , "divergent__" , "energy__", "sigma", "mu" ] + + pi = filter(p -> length(p) > 2 && p[end-1:end] == "__", cnames) + p = filter(p -> !(p in pi), cnames) + + c = Chains(a3d, + Symbol.(cnames), + Dict( + :parameters => Symbol.(p), + :internals => Symbol.(pi) + ) + ) + + c2 = Chains(a3d, + Symbol.(cnames), + Dict( + :parameters => Symbol.(p), + :internals => Symbol.(pi) + ) + ) + + tmpdir = tempdir() + open(joinpath(tmpdir, "sections_test1.txt"), "w") do io + describe(io, c, section=:parameters); + describe(io, c, section=:internals); + describe(io, c); + end + + open(joinpath(tmpdir, "sections_test2.txt"), "w") do io + describe(io, c2, section=:parameters); + describe(io, c2, section=:internals); + describe(io, c2); + end + + + @test open(f->read(f, String), joinpath(tmpdir, "sections_test1.txt")) == + open(f->read(f, String), joinpath(tmpdir, "sections_test2.txt")) end