Skip to content

Commit ad59a8e

Browse files
committed
update isdone to use state
1 parent d961513 commit ad59a8e

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

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)