1
1
# Default implementations of `sample`.
2
2
const PROGRESS = Ref (true )
3
+ const MAX_CHAINS_PROGRESS = Ref (10 )
3
4
4
5
_pluralise (n; singular= " " , plural= " s" ) = n == 1 ? singular : plural
5
6
@@ -17,6 +18,25 @@ function setprogress!(progress::Bool; silent::Bool=false)
17
18
return progress
18
19
end
19
20
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
+
20
40
function StatsBase. sample (
21
41
model_or_logdensity, sampler:: AbstractSampler , N_or_isdone; kwargs...
22
42
)
@@ -408,7 +428,7 @@ function mcmcsample(
408
428
409
429
# Determine default progress bar style.
410
430
if progress == true
411
- progress = nchains > 10 ? :overall : :perchain
431
+ progress = nchains > MAX_CHAINS_PROGRESS[] ? :overall : :perchain
412
432
elseif progress == false
413
433
progress = :none
414
434
end
0 commit comments