Skip to content

Commit 3ec158d

Browse files
authored
Merge pull request #505 from joshspeagle/eta_branch
Show the ETA during sampling using an estimate of expected number of iterations
2 parents 6f1daf7 + 87b42d2 commit 3ec158d

5 files changed

Lines changed: 187 additions & 76 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
77
[Unreleased]
88
### Added
99
### Changed
10+
- Show the ETA and expected number of iterations when sampling.
1011
- When restoring the sampler with the pool, use an updated value of `queue_size` based on the pool size
1112
- Use `chunksize=1` for the dynesty pool, as that is better behaved for `queue_size > nthreads` and unequal durations of function evaluations
1213
- When starting dynesty with a multiprocessing pool, dynesty now tries to use the `_processes` keyword to determine how many CPUs are available. This should reduce the need for manual `queue_size` specification
1314
### Fixed
15+
- Previously when restoring a saved sampler and starting running the it/s speeds shown in the progress bar were incorrect, because they did not take into account the previously evaluated iterations.
1416

1517
[3.0.0 - 2025-10-04]
1618
### Added

docs/source/faq.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,11 @@ with (3) a large number of varying live points can make the stopping criteria
261261
difficult to evaluate quickly. See
262262
:ref:`Nested Sampling Errors` for additional details.
263263

264+
**When fitting, the estimated time of sampling varies a lot from iteration to
265+
iteration**
266+
267+
This is normal. There is no way to accurately know how many iterations of nested sampling will be needed and how long it will take. The estimate of total time is particularly uncertaintain in the beginning of the sampling. The time can also jump significantly every time a new location of the in the posterior with a particularly high log(l) value is discovered.
268+
264269

265270
Live Point Questions
266271
--------------------

py/dynesty/dynamicsampler.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ def _configure_batch_sampler(main_sampler,
447447
boundidx=0,
448448
bounditer=0,
449449
eff=main_sampler.eff,
450+
delta_logz=np.nan,
450451
proposal_stats=None))
451452
batch_sampler.update_bound_if_needed(logl_min)
452453
# Trigger an update of the internal bounding distribution based
@@ -583,6 +584,7 @@ def _configure_batch_sampler(main_sampler,
583584
boundidx=live_bound[i],
584585
bounditer=live_bound[i],
585586
eff=main_sampler.eff,
587+
delta_logz=np.nan,
586588
proposal_stats=live_proposal_stats[i]))
587589
niter += nlive_new
588590
# Overwrite the previous set of live points in our internal sampler
@@ -1410,6 +1412,7 @@ def sample_batch(self,
14101412
boundidx=results.boundidx,
14111413
bounditer=results.bounditer,
14121414
eff=self.eff,
1415+
delta_logz=results.delta_logz,
14131416
proposal_stats=results.proposal_stats)
14141417
if iterated_batch and results.loglstar < logl_max and np.isfinite(
14151418
logl_max) and maxiter_left > 0 and maxcall_left > 0:
@@ -1456,6 +1459,7 @@ def sample_batch(self,
14561459
boundidx=results.boundidx,
14571460
bounditer=results.bounditer,
14581461
eff=self.eff,
1462+
delta_logz=np.nan,
14591463
proposal_stats=None)
14601464
del self.batch_sampler
14611465
self.batch_sampler = None
@@ -1822,7 +1826,9 @@ def run_nested(self,
18221826
return
18231827

18241828
# Baseline run.
1825-
pbar, print_func = get_print_func(print_func, print_progress)
1829+
pbar, print_func = get_print_func(print_func,
1830+
print_progress,
1831+
initial=self.it - 1)
18261832
self.checkpoint_timer = DelayTimer(checkpoint_every)
18271833
try:
18281834
# the init should be the first default stage, all other ones
@@ -2088,7 +2094,7 @@ def add_batch(self,
20882094
boundidx=cur_results.boundidx,
20892095
bounditer=cur_results.bounditer,
20902096
eff=cur_results.eff,
2091-
delta_logz=np.nan,
2097+
delta_logz=cur_results.delta_logz,
20922098
proposal_stats=cur_results.proposal_stats)
20932099

20942100
# Print progress.
@@ -2097,6 +2103,7 @@ def add_batch(self,
20972103
niter,
20982104
ncall,
20992105
nbatch=n + 1,
2106+
dlogz=dlogz,
21002107
stop_val=stop_val,
21012108
logl_min=logl_min,
21022109
logl_max=logl_max)

py/dynesty/sampler.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,9 @@ def run_nested(self,
12951295
return
12961296

12971297
# Run the main nested sampling loop.
1298-
pbar, print_func = get_print_func(print_func, print_progress)
1298+
pbar, print_func = get_print_func(print_func,
1299+
print_progress,
1300+
initial=self.it - 1)
12991301
if checkpoint_file is not None:
13001302
timer = DelayTimer(checkpoint_every)
13011303
try:

0 commit comments

Comments
 (0)