Skip to content

Commit 2f6d220

Browse files
authored
Merge pull request #68 from TuringLang/ml/isdone
add `state` to isdone signature
2 parents 232fb36 + ff5d718 commit 2f6d220

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ uuid = "80f14c24-f653-4e6a-9b94-39d6b0f70001"
33
keywords = ["markov chain monte carlo", "probablistic programming"]
44
license = "MIT"
55
desc = "A lightweight interface for common MCMC methods."
6-
version = "3.0.1"
6+
version = "3.0.2"
77

88
[deps]
99
BangBang = "198e06fe-97b7-11e9-32a5-e1d131e6ad66"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ StatsBase.sample(
4444
for regular and parallel sampling, respectively. In regular sampling, users may
4545
provide a function
4646
```julia
47-
isdone(rng, model, sampler, samples, iteration; kwargs...)
47+
isdone(rng, model, sampler, samples, state, iteration; kwargs...)
4848
```
4949
that returns `true` when sampling should end, and `false` otherwise, instead of
5050
a fixed number of samples `nsamples`. AbstractMCMC defines the abstract types

src/sample.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ function mcmcsample(
206206
# Step through the sampler until stopping.
207207
i = 2
208208

209-
while !isdone(rng, model, sampler, samples, i; progress=progress, kwargs...)
209+
while !isdone(rng, model, sampler, samples, state, i; progress=progress, kwargs...)
210210
# Discard thinned samples.
211211
for _ in 1:(thinning - 1)
212212
# Obtain the next sample and state.

test/utils.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,13 @@ function isdone(
5353
model::MyModel,
5454
s::MySampler,
5555
samples,
56+
state,
5657
iteration::Int;
5758
kwargs...
5859
)
5960
# Calculate the mean of x.b.
6061
bmean = mean(x.b for x in samples)
61-
return abs(bmean) <= 0.001 || iteration >= 10_000
62+
return abs(bmean) <= 0.001 || iteration >= 10_000 || state >= 10_000
6263
end
6364

6465
# Set a default convergence function.

0 commit comments

Comments
 (0)