Skip to content

Commit

Permalink
Add test for show method
Browse files Browse the repository at this point in the history
  • Loading branch information
sethaxen committed Feb 11, 2024
1 parent 3579c55 commit 5332916
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ Random.seed!(0)
println("Model statistics")
@time include("modelstats_test.jl")

# run tests for show methods
println("Show methods")
@time include("show_tests.jl")

# run tests for concatenation
println("Concatenation")
@time include("concatenation_tests.jl")
Expand Down
23 changes: 23 additions & 0 deletions test/show_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Test
using MCMCChains

@testset "Show tests" begin
rng = MersenneTwister(1234)
val = rand(rng, 100, 4, 4)
parm_names = ["a", "b", "c", "d"]
chns = Chains(val, parm_names, Dict(:internals => ["b", "d"]))[1:2:99, :, :]
str = sprint(show, "text/plain", chns)
stats_str = sprint(show, "text/plain", summarystats(chns))
quantile_str = sprint(show, "text/plain", quantile(chns))
@test str == """Chains MCMC chain (50×4×4 Array{Float64, 3}):
Iterations = 1:2:99
Number of chains = 4
Samples per chain = 50
parameters = a, c
internals = b, d
$stats_str
$quantile_str"""
end

0 comments on commit 5332916

Please sign in to comment.