Skip to content

Commit

Permalink
Updated section_tests.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
cpfiffer committed Mar 2, 2019
1 parent 134150d commit 1cdc153
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 100 deletions.
Binary file removed test/demo-plot.png
Binary file not shown.
70 changes: 0 additions & 70 deletions test/sections_test.txt

This file was deleted.

71 changes: 41 additions & 30 deletions test/sections_tests.jl
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1cdc153

Please sign in to comment.