bilby.result.read_in_result does not correctly import UniformComovingVolume prior
I read in a result using bilby.result.read_in_result
. I would like to access the priors used to obtain this result. I would like to use the prior.prob
function, but this fails due to the error:
AttributeError: 'str' object has no attribute 'prob'
When I print the type of each prior contained in my_result.priors
, I get this:
<class 'bilby.core.prior.Uniform'>
Uniform(minimum=20, maximum=60, name='mass_1', latex_label='$m_1$', unit='$M_{\\odot}$', periodic_boundary=False)
<class 'bilby.core.prior.Uniform'>
Uniform(minimum=20, maximum=60, name='mass_2', latex_label='$m_2$', unit='$M_{\\odot}$', periodic_boundary=False)
<class 'str'>
UniformComovingVolume(minimum=500.0, maximum=3000.0, cosmology=FlatLambdaCDM(name="Planck15", H0=67.7 km / (Mpc s), Om0=0.307, Tcmb0=2.725 K, Neff=3.05, m_nu=[0. 0. 0.06] eV, Ob0=0.0486), name='luminosity_distance', latex_label='$d_L$', unit=Unit("Mpc"))
Traceback (most recent call last):
File "prior_reweighting.py", line 45, in <module>
prior_weights = result.get_weights_by_new_prior(new_prior)
File "/anaconda3/lib/python3.7/site-packages/bilby-0.4.4-py3.7.egg/bilby/core/result.py", line 1198, in get_weights_by_new_prior
w *= new_priors[prior_key].prob(val) / self.priors[prior_key].prob(val)
AttributeError: 'str' object has no attribute 'prob'
I suspect this is because UniformComovingVolume
is a GW-specific prior, whilst Uniform
is part of core
, where read_in_result
is defined.