From d25d4bdb1fb5dd63704da1a3d07af4f014422276 Mon Sep 17 00:00:00 2001 From: Emma Smith Date: Tue, 31 May 2016 15:57:59 +0100 Subject: [PATCH 1/3] Adding Base.show(io::IO, ch1::Chain) function --- src/core/io.jl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/core/io.jl b/src/core/io.jl index 323bf60cc..ad0840672 100644 --- a/src/core/io.jl +++ b/src/core/io.jl @@ -13,6 +13,16 @@ type Chain end Chain() = Chain(0, Vector{Sample}()) +function Base.show(io::IO, ch1::Chain) + # Print chain weight and weighted means of samples in chain + if length(ch1.value) == 0 + print(io, "Empty Chain, weight $(ch1.weight)") + else + chain_mean = [i => mean(ch1, i, x -> x) for i in keys(ch1.value[1].value)] + print(io, "Chain, weight $(ch1.weight) and means $(chain_mean)") + end +end + function Base.getindex(c::Chain, v::Symbol) # This strange implementation is mostly to keep backward compatability. # Needs some refactoring a better format for storing results is available. @@ -54,4 +64,3 @@ end # tests # tr = Turing.sampler.particles[1] # tr = Chain(Turing.sampler.particles) - From 48617212c6cb3aecb26d81ba8018e4dabcc57c6d Mon Sep 17 00:00:00 2001 From: Hong Ge Date: Fri, 3 Jun 2016 15:09:13 +0100 Subject: [PATCH 2/3] Update io.jl --- src/core/io.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/io.jl b/src/core/io.jl index ad0840672..0237d0442 100644 --- a/src/core/io.jl +++ b/src/core/io.jl @@ -19,7 +19,7 @@ function Base.show(io::IO, ch1::Chain) print(io, "Empty Chain, weight $(ch1.weight)") else chain_mean = [i => mean(ch1, i, x -> x) for i in keys(ch1.value[1].value)] - print(io, "Chain, weight $(ch1.weight) and means $(chain_mean)") + print(io, "Chain, model edvidence (log) $(ch1.weight) and means $(chain_mean)") end end From e7a6e09d8c9b89655d6d5c8ab9764d055483b03e Mon Sep 17 00:00:00 2001 From: Hong Ge Date: Fri, 3 Jun 2016 15:10:23 +0100 Subject: [PATCH 3/3] Fix typo. --- src/core/io.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/io.jl b/src/core/io.jl index 0237d0442..edd64a55b 100644 --- a/src/core/io.jl +++ b/src/core/io.jl @@ -19,7 +19,7 @@ function Base.show(io::IO, ch1::Chain) print(io, "Empty Chain, weight $(ch1.weight)") else chain_mean = [i => mean(ch1, i, x -> x) for i in keys(ch1.value[1].value)] - print(io, "Chain, model edvidence (log) $(ch1.weight) and means $(chain_mean)") + print(io, "Chain, model evidence (log) $(ch1.weight) and means $(chain_mean)") end end