From 573a373ae2c3fe356871944bcfc891ababc11bbe Mon Sep 17 00:00:00 2001 From: Seth Axen Date: Wed, 19 Jan 2022 00:20:44 +0100 Subject: [PATCH 1/3] Convert prior predictive even if prior not provided --- src/mcmcchains.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mcmcchains.jl b/src/mcmcchains.jl index 79b1e8a3..0d207140 100644 --- a/src/mcmcchains.jl +++ b/src/mcmcchains.jl @@ -268,6 +268,14 @@ function from_mcmcchains( ), ) concat!(all_idata, prior_idata) + elseif prior_predictive !== nothing + pre_prior_predictive_idata = convert_to_inference_data( + prior_predictive; eltypes=eltypes, kwargs... + ) + concat!( + all_idata, + InferenceData(; prior_predictive=pre_prior_predictive_idata.posterior), + ) end for (group, group_data) in [ From 71215d30d7d8f4ea15996aad0dd5f204615e6bbc Mon Sep 17 00:00:00 2001 From: Seth Axen Date: Wed, 19 Jan 2022 00:20:52 +0100 Subject: [PATCH 2/3] Add test --- test/test_mcmcchains.jl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/test_mcmcchains.jl b/test/test_mcmcchains.jl index abc5ad5a..a326e823 100644 --- a/test/test_mcmcchains.jl +++ b/test/test_mcmcchains.jl @@ -250,6 +250,17 @@ end @test "z" ∈ keys(dimdict(idata.predictions_constant_data)) end + # https://github.com/arviz-devs/ArviZ.jl/issues/146 + @testset "prior predictive w/o prior" begin + nvars, nchains, ndraws = 2, 4, 20 + chns = makechains(nvars, ndraws, nchains) + prior_predictive = randn(nchains, ndraws, 1) + idata = from_mcmcchains(chns; prior_predictive=prior_predictive) + test_chains_data(chns, idata, :posterior, names(chns)) + @test :prior_predictive ∈ ArviZ.groupnames(idata) + @test idata.prior_predictive.x.values ≈ prior_predictive + end + @testset "missing -> NaN" begin rng = MersenneTwister(42) nvars, nchains, ndraws = 2, 4, 20 From 42e7cbe944de22c8627046c35ce9ec35eefc2574 Mon Sep 17 00:00:00 2001 From: Seth Axen Date: Wed, 19 Jan 2022 00:21:02 +0100 Subject: [PATCH 3/3] Increment version number --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index e5649d27..65c55411 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ArviZ" uuid = "131c737c-5715-5e2e-ad31-c244f01c1dc7" authors = ["Seth Axen "] -version = "0.5.10" +version = "0.5.11" [deps] Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d"