API changes in dynesty>=1.1 (master branch May 7th)
I tried running the linear-regression example with dynesty + the rwalk method:
#!/usr/bin/env python
import bilby
import numpy as np
import matplotlib.pyplot as plt
label = 'linear_regression'
outdir = 'outdir'
bilby.utils.check_directory_exists_and_if_not_mkdir(outdir)
def model(time, m, c):
return time * m + c
injection_parameters = dict(m=0.5, c=0.2)
sampling_frequency = 10
time_duration = 10
time = np.arange(0, time_duration, 1 / sampling_frequency)
N = len(time)
sigma = np.random.normal(1, 0.01, N)
data = model(time, **injection_parameters) + np.random.normal(0, sigma, N)
likelihood = bilby.likelihood.GaussianLikelihood(time, data, model, sigma)
priors = dict()
priors['m'] = bilby.core.prior.Uniform(0, 5, 'm')
priors['c'] = bilby.core.prior.Uniform(-2, 2, 'c')
result = bilby.run_sampler(
likelihood=likelihood, priors=priors, sampler='dynesty', nlive=500,
sample="rwalk", injection_parameters=injection_parameters, outdir=outdir, label=label, clean=True)
and got the following error after the sampling had completed and bilby was trying to save the results:
/usr/local/lib/python3.7/dist-packages/bilby/core/sampler/dynesty.py in dump_samples_to_dat(self)
601 def dump_samples_to_dat(self):
602 sampler = self.sampler
--> 603 ln_weights = sampler.saved_logwt - sampler.saved_logz[-1]
604
605 weights = np.exp(ln_weights)
AttributeError: 'MultiEllipsoidSampler' object has no attribute 'saved_logwt'
I think dynesty has gotten rid of the saved_logwt
attribute.
versions:
- Dynesty version (master branch from May 7, 2021)
- Bilby 1.1.2: (CLEAN) 15f0012b 2021-08-16 12:18:30 +1000
Edited by Avi Vajpeyi