BUG: ensure infinite ACT estimates are properly handled
@lalit.pathak reported the following error. This happens when no points are accepted during the MCMC while using ACT-walk. This is most likely a sign of some underlying pathology in the likelihood/sampling space, but we should handle the case smoothly.
Traceback (most recent call last):
File "/home/lalit.pathak/.conda/envs/gwsim_env/lib/python3.10/multiprocessing/pool.py", line 125, in worker
result = (True, func(*args, **kwds))
File "/home/lalit.pathak/.conda/envs/gwsim_env/lib/python3.10/multiprocessing/pool.py", line 48, in mapstar
return list(map(*args))
File "/home/lalit.pathak/.conda/envs/gwsim_env/lib/python3.10/site-packages/bilby/core/sampler/dynesty_utils.py", line 198, in __call__
while self.cache[0][2] < args.loglstar:
File "/home/lalit.pathak/.conda/envs/gwsim_env/lib/python3.10/site-packages/bilby/core/sampler/dynesty_utils.py", line 207, in cache
self.build_cache()
File "/home/lalit.pathak/.conda/envs/gwsim_env/lib/python3.10/site-packages/bilby/core/sampler/dynesty_utils.py", line 223, in build_cache
check_interval = int(np.ceil(self.act))
OverflowError: cannot convert float infinity to integer
I also noticed a second case where an infinity can sneak in that will break things, if there are fewer than ten live points, the acceptance walk method will fail on current master.
Traceback (most recent call last):
File "/Users/colm/modules/bilby/examples/core_examples/linear_regression.py", line 57, in <module>
result = bilby.run_sampler(
File "/Users/colm/modules/bilby/bilby/core/sampler/__init__.py", line 234, in run_sampler
result = sampler.run_sampler()
File "/Users/colm/modules/bilby/bilby/core/sampler/base_sampler.py", line 97, in wrapped
output = method(self, *args, **kwargs)
File "/Users/colm/modules/bilby/bilby/core/sampler/dynesty.py", line 517, in run_sampler
out = self._run_external_sampler_with_checkpointing()
File "/Users/colm/modules/bilby/bilby/core/sampler/dynesty.py", line 637, in _run_external_sampler_with_checkpointing
self.sampler.run_nested(**sampler_kwargs)
File "/Users/colm/modules/dynesty/py/dynesty/sampler.py", line 1057, in run_nested
for it, results in enumerate(
File "/Users/colm/modules/dynesty/py/dynesty/sampler.py", line 877, in sample
u, v, logl, nc = self._new_point(loglstar_new)
File "/Users/colm/modules/dynesty/py/dynesty/sampler.py", line 462, in _new_point
self.update_proposal(blob, update=self.nqueue <= 0)
File "/Users/colm/modules/bilby/bilby/core/sampler/dynesty_utils.py", line 56, in update_user
self.walks = (self.walks * delay + n_target / accept_prob) / (delay + 1)
ZeroDivisionError: float division by zero
Edited by Colm Talbot