Skip to content

Commit 284741f

Browse files
committed
Make :overall the default, remove setmaxchainsprogress!
1 parent 7276fc2 commit 284741f

File tree

2 files changed

+7
-29
lines changed

2 files changed

+7
-29
lines changed

docs/src/api.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,33 +103,31 @@ For single-chain sampling (i.e., `sample([rng,] model, sampler, N)`), as well as
103103

104104
For multiple-chain sampling using `MCMCThreads`, there are several, more detailed, options:
105105

106-
- `:perchain`: create one progress bar per chain being sampled, plus one progress bar tracking the number of chains
107106
- `:overall`: create one progress bar for the overall sampling process, which tracks the percentage of samples that have been sampled across all chains
107+
- `:perchain`: in addition to `:overall`, also create one progress bar for each individual chain
108108
- `:none`: do not create any progress bar
109-
- `true` (the default): use `perchain` for 10 or fewer chains, and `overall` for more than 10 chains
110-
- `false`: same as `none`, i.e. no progress bar
109+
- `true` (the default): same as `:overall`, i.e. one progress bar for the overall sampling process
110+
- `false`: same as `:none`, i.e. no progress bar
111111

112112
Multiple-chain sampling using `MCMCDistributed` behaves the same as `MCMCThreads`, except that `:perchain` is not (yet?) implemented.
113-
So, `true` always corresponds to `:overall`, and `false` corresponds to `:none`.
114113

115114
!!! warning "Do not override the `progress` keyword argument"
116115
If you are implementing your own methods for `sample(...)`, you should make sure to not override the `progress` keyword argument if you want progress logging in multi-chain sampling to work correctly, as the multi-chain `sample()` call makes sure to specifically pass custom values of `progress` to the single-chain calls.
117116

118117
### Global settings
119118

120-
If you are sampling multiple times and would like to change the default behaviour, you can use these functions to control progress logging globally:
119+
If you are sampling multiple times and would like to change the default behaviour, you can use this function to control progress logging globally:
121120

122121
```@docs
123122
AbstractMCMC.setprogress!
124-
AbstractMCMC.setmaxchainsprogress!
125123
```
126124

127125
`setprogress!` is more general, and applies to all types of sampling (both single- and multiple-chain).
128126
It only takes a boolean argument, which switches progress logging on or off.
129127
For example, `setprogress!(false)` will disable all progress logging.
130128

131-
On the other hand, `setmaxchainsprogress!` is specific to multiple-chain sampling, and allows you to set the threshold for when to switch from `:perchain` to `:overall` progress logging.
132-
Thus, for example, if you want to keep progress logging on but _always_ want to use `:overall`, you can set `AbstractMCMC.setmaxchainsprogress!(0)`.
129+
Note that `setprogress!` cannot be used to set the type of progress bar for multiple-chain sampling.
130+
If you want to use `:perchain`, it has to be set on each individual call to `sample`.
133131

134132
## Chains
135133

src/sample.jl

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Default implementations of `sample`.
22
const PROGRESS = Ref(true)
3-
const MAX_CHAINS_PROGRESS = Ref(10)
43

54
_pluralise(n; singular="", plural="s") = n == 1 ? singular : plural
65

@@ -18,25 +17,6 @@ function setprogress!(progress::Bool; silent::Bool=false)
1817
return progress
1918
end
2019

21-
"""
22-
setmaxchainsprogress!(max_chains::Int, silent::Bool=false)
23-
24-
Set the maximum number of chains to display progress bars for when sampling
25-
multiple chains at once (if progress logging is enabled). Above this limit, no
26-
progress bars are displayed for individual chains; instead, a single progress
27-
bar is displayed for the entire sampling process.
28-
"""
29-
function setmaxchainsprogress!(max_chains::Int, silent::Bool=false)
30-
if max_chains < 0
31-
throw(ArgumentError("maximum number of chains must be non-negative"))
32-
end
33-
if !silent
34-
@info "AbstractMCMC: maximum number of per-chain progress bars set to $max_chains"
35-
end
36-
MAX_CHAINS_PROGRESS[] = max_chains
37-
return nothing
38-
end
39-
4020
function StatsBase.sample(
4121
model_or_logdensity, sampler::AbstractSampler, N_or_isdone; kwargs...
4222
)
@@ -432,7 +412,7 @@ function mcmcsample(
432412

433413
# Determine default progress bar style.
434414
if progress == true
435-
progress = nchains > MAX_CHAINS_PROGRESS[] ? :overall : :perchain
415+
progress = :overall
436416
elseif progress == false
437417
progress = :none
438418
end

0 commit comments

Comments
 (0)