From ad59a8efa94bf4ca284967172e54bed33ab3d1e1 Mon Sep 17 00:00:00 2001 From: Miles Lucas Date: Sat, 10 Apr 2021 16:46:58 -0500 Subject: [PATCH 1/3] update isdone to use state --- README.md | 2 +- src/sample.jl | 2 +- test/utils.jl | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 56b8093d..340e1cb7 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ StatsBase.sample( for regular and parallel sampling, respectively. In regular sampling, users may provide a function ```julia -isdone(rng, model, sampler, samples, iteration; kwargs...) +isdone(rng, model, sampler, samples, state, iteration; kwargs...) ``` that returns `true` when sampling should end, and `false` otherwise, instead of a fixed number of samples `nsamples`. AbstractMCMC defines the abstract types diff --git a/src/sample.jl b/src/sample.jl index 563d4652..7585458b 100644 --- a/src/sample.jl +++ b/src/sample.jl @@ -206,7 +206,7 @@ function mcmcsample( # Step through the sampler until stopping. i = 2 - while !isdone(rng, model, sampler, samples, i; progress=progress, kwargs...) + while !isdone(rng, model, sampler, samples, state, i; progress=progress, kwargs...) # Discard thinned samples. for _ in 1:(thinning - 1) # Obtain the next sample and state. diff --git a/test/utils.jl b/test/utils.jl index abab2b73..b8adcd90 100644 --- a/test/utils.jl +++ b/test/utils.jl @@ -53,12 +53,13 @@ function isdone( model::MyModel, s::MySampler, samples, + state, iteration::Int; kwargs... ) # Calculate the mean of x.b. bmean = mean(x.b for x in samples) - return abs(bmean) <= 0.001 || iteration >= 10_000 + return abs(bmean) <= 0.001 || iteration >= 10_000 || state >= 10_000 end # Set a default convergence function. From 43398e96ab2cd62653451a87f964c3ea4c4873ea Mon Sep 17 00:00:00 2001 From: Miles Lucas Date: Sat, 10 Apr 2021 16:48:47 -0500 Subject: [PATCH 2/3] bump version to 4.0.0 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 477ccc9d..11c803a9 100644 --- a/Project.toml +++ b/Project.toml @@ -3,7 +3,7 @@ uuid = "80f14c24-f653-4e6a-9b94-39d6b0f70001" keywords = ["markov chain monte carlo", "probablistic programming"] license = "MIT" desc = "A lightweight interface for common MCMC methods." -version = "3.0.0" +version = "4.0.0" [deps] BangBang = "198e06fe-97b7-11e9-32a5-e1d131e6ad66" From ff5d7188b929aeb3f1476c5b19797cf851a606a6 Mon Sep 17 00:00:00 2001 From: Miles Lucas Date: Sat, 10 Apr 2021 17:48:27 -0500 Subject: [PATCH 3/3] Update Project.toml Co-authored-by: Cameron Pfiffer --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 11c803a9..9bfc1259 100644 --- a/Project.toml +++ b/Project.toml @@ -3,7 +3,7 @@ uuid = "80f14c24-f653-4e6a-9b94-39d6b0f70001" keywords = ["markov chain monte carlo", "probablistic programming"] license = "MIT" desc = "A lightweight interface for common MCMC methods." -version = "4.0.0" +version = "3.0.2" [deps] BangBang = "198e06fe-97b7-11e9-32a5-e1d131e6ad66"