Skip to content

Commit

Permalink
Merge pull request #32 from TuringLang/csp/fileio
Browse files Browse the repository at this point in the history
  • Loading branch information
cpfiffer authored Feb 10, 2019
2 parents 66c942f + 3d3c978 commit c422398
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/MCMCChain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Showoff: showoff
import StatsBase: autocor, autocov, countmap, counts, describe, predict,
quantile, sample, sem, summarystats
import LinearAlgebra: diag
import Serialization: serialize, deserialize

using RecipesBase
import RecipesBase: plot
Expand Down
15 changes: 14 additions & 1 deletion test/diagnostic_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ end
# do not test the following functions
# - wrtsp
# - window2inds (tested above, see getindex)
# -
# -

# the following tests only check if the function calls work!
@test MCMCChain.diag_all(rand(100, 2), :weiss, 1, 1, 1) != nothing
Expand All @@ -44,3 +44,16 @@ end
@test isa(heideldiag(chn[:,1,:]), MCMCChain.ChainSummary)
@test isa(rafterydiag(chn[:,1,:]), MCMCChain.ChainSummary)
end

@testset "File IO" begin
loc = mktempdir()

# Serialize and deserialize.
write(joinpath(loc, "chain1"), chn)
chn2 = read(joinpath(loc, "chain1"), Chains)

# Test that the values were read correctly.
@test chn2.value == chn.value

rm(loc; force=true, recursive=true)
end

0 comments on commit c422398

Please sign in to comment.