Skip to content

Commit 3e43f6a

Browse files
committed
Add exclamation marks to function names
1 parent 9f8970d commit 3e43f6a

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

src/logging.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ struct CreateNewProgressBar{S<:AbstractString} <: AbstractProgressKwarg
1818
return new{typeof(name)}(name, UUIDs.uuid4())
1919
end
2020
end
21-
function init_progress(p::CreateNewProgressBar)
21+
function init_progress!(p::CreateNewProgressBar)
2222
ProgressLogging.@logprogress p.name nothing _id = p.uuid
2323
end
24-
function update_progress(p::CreateNewProgressBar, progress_frac)
24+
function update_progress!(p::CreateNewProgressBar, progress_frac)
2525
ProgressLogging.@logprogress p.name progress_frac _id = p.uuid
2626
end
27-
function finish_progress(p::CreateNewProgressBar)
27+
function finish_progress!(p::CreateNewProgressBar)
2828
ProgressLogging.@logprogress p.name "done" _id = p.uuid
2929
end
3030

@@ -34,9 +34,9 @@ end
3434
Do not log progress at all.
3535
"""
3636
struct NoLogging <: AbstractProgressKwarg end
37-
init_progress(::NoLogging) = nothing
38-
update_progress(::NoLogging, ::Any) = nothing
39-
finish_progress(::NoLogging) = nothing
37+
init_progress!(::NoLogging) = nothing
38+
update_progress!(::NoLogging, ::Any) = nothing
39+
finish_progress!(::NoLogging) = nothing
4040

4141
"""
4242
ExistingProgressBar
@@ -51,7 +51,7 @@ struct ExistingProgressBar{S<:AbstractString} <: AbstractProgressKwarg
5151
name::S
5252
uuid::UUIDs.UUID
5353
end
54-
function init_progress(p::ExistingProgressBar)
54+
function init_progress!(p::ExistingProgressBar)
5555
# Hacky code to reset the start timer if called from a multi-chain sampling
5656
# process. We need this because the progress bar is constructed in the
5757
# multi-chain method, i.e. if we don't do this the progress bar shows the
@@ -65,10 +65,10 @@ function init_progress(p::ExistingProgressBar)
6565
end
6666
ProgressLogging.@logprogress p.name nothing _id = p.uuid
6767
end
68-
function update_progress(p::ExistingProgressBar, progress_frac)
68+
function update_progress!(p::ExistingProgressBar, progress_frac)
6969
ProgressLogging.@logprogress p.name progress_frac _id = p.uuid
7070
end
71-
function finish_progress(p::ExistingProgressBar)
71+
function finish_progress!(p::ExistingProgressBar)
7272
ProgressLogging.@logprogress p.name "done" _id = p.uuid
7373
end
7474

@@ -87,11 +87,11 @@ struct ChannelProgress{T<:Union{Channel{Bool},Distributed.RemoteChannel{Channel{
8787
channel::T
8888
n_updates::Int
8989
end
90-
init_progress(::ChannelProgress) = nothing
91-
update_progress(p::ChannelProgress, ::Any) = put!(p.channel, true)
90+
init_progress!(::ChannelProgress) = nothing
91+
update_progress!(p::ChannelProgress, ::Any) = put!(p.channel, true)
9292
# Note: We don't want to `put!(p.channel, false)`, because that would stop the
9393
# channel from being used for further updates e.g. from other chains.
94-
finish_progress(::ChannelProgress) = nothing
94+
finish_progress!(::ChannelProgress) = nothing
9595

9696
# Add a custom progress logger if the current logger does not seem to be able to handle
9797
# progress logs.

src/sample.jl

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ function mcmcsample(
169169
local state
170170

171171
@maybewithricherlogger begin
172-
init_progress(progress)
172+
init_progress!(progress)
173173
# Determine threshold values for progress logging (by default, one
174174
# update per 0.5% of progress, unless this has been passed in
175175
# explicitly)
@@ -195,7 +195,7 @@ function mcmcsample(
195195
# Start the progress bar.
196196
itotal = 1
197197
if itotal >= next_update
198-
update_progress(progress, itotal / Ntotal)
198+
update_progress!(progress, itotal / Ntotal)
199199
next_update += threshold
200200
end
201201

@@ -211,7 +211,7 @@ function mcmcsample(
211211
# Update the progress bar.
212212
itotal += 1
213213
if itotal >= next_update
214-
update_progress(progress, itotal / Ntotal)
214+
update_progress!(progress, itotal / Ntotal)
215215
next_update += threshold
216216
end
217217
end
@@ -237,7 +237,7 @@ function mcmcsample(
237237
# Update progress bar.
238238
itotal += 1
239239
if itotal >= next_update
240-
update_progress(progress, itotal / Ntotal)
240+
update_progress!(progress, itotal / Ntotal)
241241
next_update += threshold
242242
end
243243
end
@@ -259,11 +259,11 @@ function mcmcsample(
259259
# Update the progress bar.
260260
itotal += 1
261261
if itotal >= next_update
262-
update_progress(progress, itotal / Ntotal)
262+
update_progress!(progress, itotal / Ntotal)
263263
next_update += threshold
264264
end
265265
end
266-
finish_progress(progress)
266+
finish_progress!(progress)
267267
end
268268

269269
# Get the sample stop time.
@@ -322,7 +322,7 @@ function mcmcsample(
322322
local state
323323

324324
@maybewithricherlogger begin
325-
init_progress(progress)
325+
init_progress!(progress)
326326
# Obtain the initial sample and state.
327327
sample, state = if num_warmup > 0
328328
if initial_state === nothing
@@ -385,7 +385,7 @@ function mcmcsample(
385385
# Increment iteration counter.
386386
i += 1
387387
end
388-
finish_progress(progress)
388+
finish_progress!(progress)
389389
end
390390

391391
# Get the sample stop time.
@@ -474,7 +474,7 @@ function mcmcsample(
474474
# by a channel, but it is not itself a ChannelProgress (because
475475
# ChannelProgress doesn't come with a progress bar).
476476
overall_progress_bar = CreateNewProgressBar(progressname)
477-
init_progress(overall_progress_bar)
477+
init_progress!(overall_progress_bar)
478478
# These are the per-chain progress bars. We generate `nchains`
479479
# independent UUIDs for each progress bar
480480
child_progresses = [
@@ -484,7 +484,7 @@ function mcmcsample(
484484
# ProgressLogging prints from the bottom up, and we want chain 1 to
485485
# show up at the top)
486486
for child_progress in reverse(child_progresses)
487-
init_progress(child_progress)
487+
init_progress!(child_progress)
488488
end
489489
updates_per_chain = nothing
490490
elseif progress == :overall
@@ -518,11 +518,11 @@ function mcmcsample(
518518
while take!(progress_channel)
519519
itotal += 1
520520
if itotal >= next_update
521-
update_progress(overall_progress_bar, itotal / Ntotal)
521+
update_progress!(overall_progress_bar, itotal / Ntotal)
522522
next_update += threshold
523523
end
524524
end
525-
finish_progress(overall_progress_bar)
525+
finish_progress!(overall_progress_bar)
526526
end
527527
end
528528

@@ -578,7 +578,7 @@ function mcmcsample(
578578
# Tell the 'main' progress bar that this chain is done.
579579
put!(progress_channel, true)
580580
# Conclude the per-chain progress bar.
581-
finish_progress(child_progresses[chainidx])
581+
finish_progress!(child_progresses[chainidx])
582582
end
583583
# Note that if progress == :overall, we don't need to do anything
584584
# because progress on that bar is triggered by
@@ -593,7 +593,7 @@ function mcmcsample(
593593
put!(progress_channel, false)
594594
# Additionally stop the per-chain progress bars
595595
for child_progress in child_progresses
596-
finish_progress(child_progress)
596+
finish_progress!(child_progress)
597597
end
598598
elseif progress == :overall
599599
# Stop updating the main progress bar (either if sampling
@@ -670,7 +670,7 @@ function mcmcsample(
670670
chan = Channel{Bool}(Distributed.nworkers())
671671
progress_channel = Distributed.RemoteChannel(() -> chan)
672672
overall_progress_bar = CreateNewProgressBar(progressname)
673-
init_progress(overall_progress_bar)
673+
init_progress!(overall_progress_bar)
674674
# See MCMCThreads method for the rationale behind updates_per_chain.
675675
updates_per_chain = max(1, 400 ÷ nchains)
676676
child_progresses = [
@@ -694,11 +694,11 @@ function mcmcsample(
694694
while take!(progress_channel)
695695
itotal += 1
696696
if itotal >= next_update
697-
update_progress(overall_progress_bar, itotal / Ntotal)
697+
update_progress!(overall_progress_bar, itotal / Ntotal)
698698
next_update += threshold
699699
end
700700
end
701-
finish_progress(overall_progress_bar)
701+
finish_progress!(overall_progress_bar)
702702
end
703703
end
704704

0 commit comments

Comments
 (0)