Skip to content

Commit 7276fc2

Browse files
committed
Improve clarity of user-facing documentation
1 parent 3e43f6a commit 7276fc2

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

docs/src/api.md

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,32 +92,45 @@ To ensure that sampling multiple chains "just works" when sampling of a single c
9292

9393
## Progress logging
9494

95-
The default value for the `progress` keyword argument is `AbstractMCMC.PROGRESS[]`, which is always set to `true` unless modified with `AbstractMCMC.setprogress!`.
96-
For example, `setprogress!(false)` will disable all progress logging.
95+
Progress logging is controlled in one of two ways:
9796

98-
```@docs
99-
AbstractMCMC.setprogress!
100-
```
97+
- by passing the `progress` keyword argument to the `sample(...)` function, or
98+
- by globally changing the defaults with `AbstractMCMC.setprogress!` and `AbstractMCMC.setmaxchainsprogress!`.
99+
100+
### `progress` keyword argument
101101

102102
For single-chain sampling (i.e., `sample([rng,] model, sampler, N)`), as well as multiple-chain sampling with `MCMCSerial`, the `progress` keyword argument should be a `Bool`.
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
106+
- `:perchain`: create one progress bar per chain being sampled, plus one progress bar tracking the number of chains
107107
- `:overall`: create one progress bar for the overall sampling process, which tracks the percentage of samples that have been sampled across all chains
108108
- `:none`: do not create any progress bar
109109
- `true` (the default): use `perchain` for 10 or fewer chains, and `overall` for more than 10 chains
110110
- `false`: same as `none`, i.e. no progress bar
111111

112-
The threshold of 10 chains can be changed using `AbstractMCMC.setmaxchainsprogress!(N)`, which will cause `MCMCThreads` to use `:perchain` for `N` or fewer chains, and `:overall` for more than `N` chains.
113-
Thus, for example, if you _always_ want to use `:overall`, you can call `AbstractMCMC.setmaxchainsprogress!(0)`.
114-
115112
Multiple-chain sampling using `MCMCDistributed` behaves the same as `MCMCThreads`, except that `:perchain` is not (yet?) implemented.
116113
So, `true` always corresponds to `:overall`, and `false` corresponds to `:none`.
117114

118115
!!! warning "Do not override the `progress` keyword argument"
119116
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.
120117

118+
### Global settings
119+
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:
121+
122+
```@docs
123+
AbstractMCMC.setprogress!
124+
AbstractMCMC.setmaxchainsprogress!
125+
```
126+
127+
`setprogress!` is more general, and applies to all types of sampling (both single- and multiple-chain).
128+
It only takes a boolean argument, which switches progress logging on or off.
129+
For example, `setprogress!(false)` will disable all progress logging.
130+
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)`.
133+
121134
## Chains
122135

123136
The `chain_type` keyword argument allows to set the type of the returned chain. A common

0 commit comments

Comments
 (0)