diff --git a/bilby/core/sampler/dynesty.py b/bilby/core/sampler/dynesty.py index 6dcf9fd13a793d9059875094513dabc712b2843a..64e1b18827ec0f309fcbd0df42347052c7dd9502 100644 --- a/bilby/core/sampler/dynesty.py +++ b/bilby/core/sampler/dynesty.py @@ -685,9 +685,9 @@ def sample_rwalk_bilby(args): reject = 0 nfail = 0 act = np.inf - u_list = [u] - v_list = [prior_transform(u)] - logl_list = [loglikelihood(v_list[-1])] + u_list = [] + v_list = [] + logl_list = [] max_walk_warning = True while len(u_list) < nact * act: @@ -748,7 +748,7 @@ def sample_rwalk_bilby(args): old_act=old_act, maxmcmc=maxmcmc) # If we've taken too many likelihood evaluations then break - if accept + reject > maxmcmc and accept > 0: + if accept + reject > maxmcmc: if max_walk_warning: warnings.warn( "Hit maximum number of walks {} with accept={}, reject={}, " @@ -765,17 +765,11 @@ def sample_rwalk_bilby(args): u = u_list[idx] v = v_list[idx] logl = logl_list[idx] - elif len(u_list) == 1: - logger.warning("Returning the only point in the chain") - u = u_list[-1] - v = v_list[-1] - logl = logl_list[-1] else: - idx = np.random.randint(int(len(u_list) / 2), len(u_list)) - logger.warning("Returning random point in second half of the chain") - u = u_list[idx] - v = v_list[idx] - logl = logl_list[idx] + logger.warning("Unable to find a new point using walk: returning a random point") + u = np.random.uniform(size=n) + v = prior_transform(u) + logl = loglikelihood(v) blob = {'accept': accept, 'reject': reject, 'fail': nfail, 'scale': scale} kwargs["old_act"] = act