Skip to content

Commit 27569b3

Browse files
committed
Don't use integer division
1 parent 64b0bfb commit 27569b3

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/logging.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ function init_progress(p::CreateNewProgressBar)
2323
end
2424
function update_progress(p::CreateNewProgressBar, progress_frac)
2525
ProgressLogging.@logprogress p.name progress_frac _id = p.uuid
26+
@show progress_frac
2627
end
2728
function finish_progress(p::CreateNewProgressBar)
2829
ProgressLogging.@logprogress p.name "done" _id = p.uuid

src/sample.jl

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,11 @@ function mcmcsample(
170170

171171
@withprogresslogger begin
172172
init_progress(progress)
173-
# Determine threshold values for progress logging
174-
# (one update per 0.5% of progress)
173+
# Determine threshold values for progress logging (by default, one
174+
# update per 0.5% of progress, unless this has been passed in
175+
# explicitly)
175176
n_updates = progress isa ChannelProgress ? progress.n_updates : 200
176-
threshold = Ntotal ÷ n_updates
177+
threshold = Ntotal / n_updates
177178
next_update = threshold
178179

179180
# Obtain the initial sample and state.
@@ -195,7 +196,7 @@ function mcmcsample(
195196
itotal = 1
196197
if itotal >= next_update
197198
update_progress(progress, itotal / Ntotal)
198-
next_update = itotal + threshold
199+
next_update += threshold
199200
end
200201

201202
# Discard initial samples.
@@ -211,7 +212,7 @@ function mcmcsample(
211212
itotal += 1
212213
if itotal >= next_update
213214
update_progress(progress, itotal / Ntotal)
214-
next_update = itotal + threshold
215+
next_update += threshold
215216
end
216217
end
217218

@@ -237,7 +238,7 @@ function mcmcsample(
237238
itotal += 1
238239
if itotal >= next_update
239240
update_progress(progress, itotal / Ntotal)
240-
next_update = itotal + threshold
241+
next_update += threshold
241242
end
242243
end
243244

@@ -259,7 +260,7 @@ function mcmcsample(
259260
itotal += 1
260261
if itotal >= next_update
261262
update_progress(progress, itotal / Ntotal)
262-
next_update = itotal + threshold
263+
next_update += threshold
263264
end
264265
end
265266
finish_progress(progress)
@@ -510,15 +511,15 @@ function mcmcsample(
510511
Ntotal = progress == :overall ? nchains * updates_per_chain : nchains
511512
# Determine threshold values for progress logging
512513
# (one update per 0.5% of progress)
513-
threshold = Ntotal ÷ 200
514+
threshold = Ntotal / 200
514515
next_update = threshold
515516

516517
itotal = 0
517518
while take!(progress_channel)
518519
itotal += 1
519520
if itotal >= next_update
520521
update_progress(overall_progress_bar, itotal / Ntotal)
521-
next_update = itotal + threshold
522+
next_update += threshold
522523
end
523524
end
524525
finish_progress(overall_progress_bar)
@@ -686,15 +687,15 @@ function mcmcsample(
686687
# Determine threshold values for progress logging
687688
# (one update per 0.5% of progress)
688689
Ntotal = nchains * updates_per_chain
689-
threshold = Ntotal ÷ 200
690+
threshold = Ntotal / 200
690691
next_update = threshold
691692

692693
itotal = 0
693694
while take!(progress_channel)
694695
itotal += 1
695696
if itotal >= next_update
696697
update_progress(overall_progress_bar, itotal / Ntotal)
697-
next_update = itotal + threshold
698+
next_update += threshold
698699
end
699700
end
700701
finish_progress(overall_progress_bar)

0 commit comments

Comments
 (0)