Skip to content

Commit

Permalink
fixed issues caused by renaming. In favor of #7 and JuliaLang/METADAT…
Browse files Browse the repository at this point in the history
  • Loading branch information
trappmartin committed Aug 23, 2018
1 parent 73756a2 commit ef9a1c1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 239 deletions.
22 changes: 11 additions & 11 deletions src/plot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ using StatPlots
import Plots.plot
#################### Posterior Plot Recipies ####################

@recipe function plot(c::Chain.AbstractChains, ptypes::Vector{Symbol};
@recipe function plot(c::MCMCChain.AbstractChains, ptypes::Vector{Symbol};
maxlag = round(Int, 10 * log10(length(c.range))),
barbounds = (0, Inf))

Expand All @@ -26,11 +26,11 @@ import Plots.plot
subplot := indices[i, j]
title := c.names[i]
labels := map(k -> "Chain $k", 1:nchains)
Chain.cummean(c.value[:, i, :])
MCMCChain.cummean(c.value[:, i, :])
end
end
elseif ptype == :autocor
ac = Chain.autocor(c, lags=collect(lags))
ac = MCMCChain.autocor(c, lags=collect(lags))
for i in 1:nvars
@series begin
seriestype := :line
Expand All @@ -43,7 +43,7 @@ import Plots.plot
end
end
elseif ptype == :mixeddensity
discrete = Chain.indiscretesupport(c, barbounds)
discrete = MCMCChain.indiscretesupport(c, barbounds)
for i in 1:nvars
@series begin
seriestype := discrete[i] ? :histogram : :density
Expand Down Expand Up @@ -71,11 +71,11 @@ import Plots.plot
end
end

plot(c::Chain.AbstractChains, ptype::Symbol; args...) = plot(c, [ptype]; args...)
plot(c::MCMCChain.AbstractChains, ptype::Symbol; args...) = plot(c, [ptype]; args...)

meanplot(c::Chain.AbstractChains; args...) = plot(c, [:mean]; args...)
autocorplot(c::Chain.AbstractChains; args...) = plot(c, [:autocor]; args...)
histogramplot(c::Chain.AbstractChains; args...) = plot(c, [:histogram]; args...)
densityplot(c::Chain.AbstractChains; args...) = plot(c, [:density]; args...)
mixeddensityplot(c::Chain.AbstractChains; args...) = plot(c, [:mixeddensity]; args...)
traceplot(c::Chain.AbstractChains; args...) = plot(c, [:trace]; args...)
meanplot(c::MCMCChain.AbstractChains; args...) = plot(c, [:mean]; args...)
autocorplot(c::MCMCChain.AbstractChains; args...) = plot(c, [:autocor]; args...)
histogramplot(c::MCMCChain.AbstractChains; args...) = plot(c, [:histogram]; args...)
densityplot(c::MCMCChain.AbstractChains; args...) = plot(c, [:density]; args...)
mixeddensityplot(c::MCMCChain.AbstractChains; args...) = plot(c, [:mixeddensity]; args...)
traceplot(c::MCMCChain.AbstractChains; args...) = plot(c, [:trace]; args...)
217 changes: 0 additions & 217 deletions src/plot_old.jl

This file was deleted.

22 changes: 11 additions & 11 deletions test/diagnostic_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ chn = Chains(val, start = 1, thin = 2)
@test last(chn) == 999
@test size(chn) == (999, 4, 2)
@test keys(chn) == ["Param1", "Param2", "Param3", "Param4"]
@test isa(chn[:,1,:], Chain.AbstractChains)
@test isa(chn[:,1,:], MCMCChain.AbstractChains)
@test length(vec(chn[:,1,:].value)) == n_chain * n_iter
@test all(chn[:,1,1].value .== val[:,1,1])
@test all(chn[:,1,2].value .== val[:,1,2])
@test all(Chain.indiscretesupport(chn) .== [false, false, false, true])
@test all(MCMCChain.indiscretesupport(chn) .== [false, false, false, true])
end

@testset "function tests" begin
Expand All @@ -35,15 +35,15 @@ end
# -

# the following tests only check if the function calls work!
@test Chain.diag_all(rand(100, 2), :weiss, 1, 1, 1) != nothing
@test Chain.diag_all(rand(100, 2), :hangartner, 1, 1, 1) != nothing
@test Chain.diag_all(rand(100, 2), :billingsley, 1, 1, 1) != nothing

@test isa(discretediag(chn[:,4,:]), Chain.ChainSummary)
@test isa(gelmandiag(chn[:,1,:]), Chain.ChainSummary)
@test isa(gewekediag(chn[:,1,:]), Chain.ChainSummary)
@test isa(heideldiag(chn[:,1,:]), Chain.ChainSummary)
@test isa(rafterydiag(chn[:,1,:]), Chain.ChainSummary)
@test MCMCChain.diag_all(rand(100, 2), :weiss, 1, 1, 1) != nothing
@test MCMCChain.diag_all(rand(100, 2), :hangartner, 1, 1, 1) != nothing
@test MCMCChain.diag_all(rand(100, 2), :billingsley, 1, 1, 1) != nothing

@test isa(discretediag(chn[:,4,:]), MCMCChain.ChainSummary)
@test isa(gelmandiag(chn[:,1,:]), MCMCChain.ChainSummary)
@test isa(gewekediag(chn[:,1,:]), MCMCChain.ChainSummary)
@test isa(heideldiag(chn[:,1,:]), MCMCChain.ChainSummary)
@test isa(rafterydiag(chn[:,1,:]), MCMCChain.ChainSummary)


end

0 comments on commit ef9a1c1

Please sign in to comment.