Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • john-veitch/bilby
  • duncanmmacleod/bilby
  • colm.talbot/bilby
  • lscsoft/bilby
  • matthew-pitkin/bilby
  • salvatore-vitale/tupak
  • charlie.hoy/bilby
  • bfarr/bilby
  • virginia.demilio/bilby
  • vivien/bilby
  • eric-howell/bilby
  • sebastian-khan/bilby
  • rhys.green/bilby
  • moritz.huebner/bilby
  • joseph.mills/bilby
  • scott.coughlin/bilby
  • matthew.carney/bilby
  • hyungwon.lee/bilby
  • monica.rizzo/bilby
  • christopher-berry/bilby
  • lindsay.demarchi/bilby
  • kaushik.rao/bilby
  • charles.kimball/bilby
  • andrew.matas/bilby
  • juan.calderonbustillo/bilby
  • patrick-meyers/bilby
  • hannah.middleton/bilby
  • eve.chase/bilby
  • grant.meadors/bilby
  • khun.phukon/bilby
  • sumeet.kulkarni/bilby
  • daniel.reardon/bilby
  • cjhaster/bilby
  • sylvia.biscoveanu/bilby
  • james-clark/bilby
  • meg.millhouse/bilby
  • joshua.willis/bilby
  • nikhil.sarin/bilby
  • paul.easter/bilby
  • youngmin/bilby
  • daniel-williams/bilby
  • shanika.galaudage/bilby
  • bruce.edelman/bilby
  • avi.vajpeyi/bilby
  • isobel.romero-shaw/bilby
  • andrew.kim/bilby
  • dominika.zieba/bilby
  • jonathan.davies/bilby
  • marc.arene/bilby
  • srishti.tiwari/bilby-tidal-heating-eccentric
  • aditya.vijaykumar/bilby
  • michael.williams/bilby
  • cecilio.garcia-quiros/bilby
  • rory-smith/bilby
  • maite.mateu-lucena/bilby
  • wushichao/bilby
  • kaylee.desoto/bilby
  • brandon.piotrzkowski/bilby
  • rossella.gamba/bilby
  • hunter.gabbard/bilby
  • deep.chatterjee/bilby
  • tathagata.ghosh/bilby
  • arunava.mukherjee/bilby
  • philip.relton/bilby
  • reed.essick/bilby
  • pawan.gupta/bilby
  • francisco.hernandez/bilby
  • rhiannon.udall/bilby
  • leo.tsukada/bilby
  • will-farr/bilby
  • vijay.varma/bilby
  • jeremy.baier/bilby
  • joshua.brandt/bilby
  • ethan.payne/bilby
  • ka-lok.lo/bilby
  • antoni.ramos-buades/bilby
  • oliviastephany.wilk/bilby
  • jack.heinzel/bilby
  • samson.leong/bilby-psi4
  • viviana.caceres/bilby
  • nadia.qutob/bilby
  • michael-coughlin/bilby
  • hemantakumar.phurailatpam/bilby
  • boris.goncharov/bilby
  • sama.al-shammari/bilby
  • siqi.zhong/bilby
  • jocelyn-read/bilby
  • marc.penuliar/bilby
  • stephanie.letourneau/bilby
  • alexandresebastien.goettel/bilby
  • alec.gunny/bilby
  • serguei.ossokine/bilby
  • pratyusava.baral/bilby
  • sophie.hourihane/bilby
  • eunsub/bilby
  • james.hart/bilby
  • pratyusava.baral/bilby-tg
  • zhaozc/bilby
  • pratyusava.baral/bilby_SoG
  • tomasz.baka/bilby
  • nicogerardo.bers/bilby
  • soumen.roy/bilby
  • isaac.mcmahon/healpix-redundancy
  • asamakai.baker/bilby-frequency-dependent-antenna-pattern-functions
  • anna.puecher/bilby
  • pratyusava.baral/bilby-x-g
  • thibeau.wouters/bilby
  • christian.adamcewicz/bilby
  • raffi.enficiaud/bilby
109 results
Show changes
Commits on Source (27)
Showing
with 91 additions and 22 deletions
......@@ -3,3 +3,4 @@ omit =
test/integration/example_test.py
test/integration/noise_realisation_test.py
test/integration/other_test.py
bilby/_version.py
......@@ -15,3 +15,4 @@ MANIFEST
*.ipynb_checkpoints
outdir/*
.idea/*
bilby/_version.py
......@@ -24,6 +24,7 @@ Eric Thrane
Ethan Payne
Francisco Javier Hernandez
Gregory Ashton
Hank Hua
Hector Estelles
Ignacio Magaña Hernandez
Isobel Marguarethe Romero-Shaw
......@@ -34,6 +35,7 @@ Jeremy G Baier
John Veitch
Joshua Brandt
Josh Willis
Karl Wette
Katerina Chatziioannou
Kaylee de Soto
Khun Sang Phukon
......@@ -59,6 +61,7 @@ Paul Easter
Paul Lasky
Philip Relton
Rhys Green
Richard Udall
Rico Lo
Roberto Cotesta
Rory Smith
......@@ -75,7 +78,9 @@ Stephen R Green
Sumeet Kulkarni
Sylvia Biscoveanu
Tathagata Ghosh
Tomasz Baka
Will M. Farr
Virginia d'Emilio
Vivien Raymond
Ka-Lok Lo
Isaac Legred
\ No newline at end of file
Isaac Legred
# All notable changes will be documented in this file
## [1.2.1] 2022-09-05
Version 1.2.1 release of Bilby
This release contains a few bug fixes following 1.2.0.
### Changes
- Improve how sampling seed is handled across samplers (!1134)
- Make sure labels are included when evidences are in corner plot legend (!1135)
- Remove calls to `getargspec` (!1136)
- Make sure parameter reconstruction cache is not mangled when reading (!1126)
- Enable the constant uncertainty calibration spline to have a specifiable boundary condition (!1137)
- Fix a bug in checkpointing for `bilby_mcmc` (!1141)
- Fix the `LALCBCWaveformGenerator` (!1140)
- Switch to automatic versioning with `setuptools_scm` (!1125)
- Improve the stability of the multivariate normal prior (!1142)
- Extend mass conversions to include source-frame parameters (!1131)
- Fix prior ranges for GW150914 example (!1129)
## [1.2.0] 2022-08-15
Version 1.2.0 release of Bilby
......
......@@ -5,4 +5,5 @@ include gw_requirements.txt
include mcmc_requirements.txt
include optional_requirements.txt
include sampler_requirements.txt
include bilby/_version.py
recursive-include test *.py *.prior
......@@ -24,7 +24,10 @@ from .core import utils, likelihood, prior, result, sampler
from .core.sampler import run_sampler
from .core.likelihood import Likelihood
__version__ = utils.get_version_information()
try:
from ._version import version as __version__
except ModuleNotFoundError: # development mode
__version__ = 'unknown'
if sys.version_info < (3,):
......
......@@ -202,6 +202,7 @@ class Bilby_MCMC(MCMCSampler):
logger.warning("Burn-in inefficiency fraction greater than 10%")
def _translate_kwargs(self, kwargs):
kwargs = super()._translate_kwargs(kwargs)
if "printdt" not in kwargs:
for equiv in ["print_dt", "print_update"]:
if equiv in kwargs:
......@@ -1075,9 +1076,6 @@ class BilbyMCMCSampler(object):
Eindex=0,
use_ratio=False,
):
from ..core.sampler.base_sampler import _sampling_convenience_dump
self._sampling_helper = _sampling_convenience_dump
self.beta = beta
self.Tindex = Tindex
self.Eindex = Eindex
......
......@@ -382,6 +382,7 @@ class MultivariateGaussianDist(BaseJointPriorDist):
self.covs = []
self.corrcoefs = []
self.sigmas = []
self.logprodsigmas = [] # log of product of sigmas, needed for "standard" multivariate normal
self.weights = []
self.eigvalues = []
self.eigvectors = []
......@@ -528,6 +529,9 @@ class MultivariateGaussianDist(BaseJointPriorDist):
self.covs.append(np.eye(self.num_vars))
self.sigmas.append(np.ones(self.num_vars))
# compute log of product of sigmas, needed for "standard" multivariate normal
self.logprodsigmas.append(np.log(np.prod(self.sigmas[-1])))
# get eigen values and vectors
try:
evals, evecs = np.linalg.eig(self.corrcoefs[-1])
......@@ -557,9 +561,16 @@ class MultivariateGaussianDist(BaseJointPriorDist):
# add the mode
self.nmodes += 1
# add multivariate Gaussian
# add "standard" multivariate normal distribution
# - when the typical scales of the parameters are very different,
# multivariate_normal() may complain that the covariance matrix is singular
# - instead pass zero means and correlation matrix instead of covariance matrix
# to get the equivalent of a standard normal distribution in higher dimensions
# - this modifies the multivariate normal PDF as follows:
# multivariate_normal(mean=mus, cov=cov).logpdf(x)
# = multivariate_normal(mean=0, cov=corrcoefs).logpdf((x - mus)/sigmas) - logprodsigmas
self.mvn.append(
scipy.stats.multivariate_normal(mean=self.mus[-1], cov=self.covs[-1])
scipy.stats.multivariate_normal(mean=np.zeros(self.num_vars), cov=self.corrcoefs[-1])
)
def _rescale(self, samp, **kwargs):
......@@ -630,7 +641,9 @@ class MultivariateGaussianDist(BaseJointPriorDist):
for j in range(samp.shape[0]):
# loop over the modes and sum the probabilities
for i in range(self.nmodes):
lnprob[j] = np.logaddexp(lnprob[j], self.mvn[i].logpdf(samp[j]))
# self.mvn[i] is a "standard" multivariate normal distribution; see add_mode()
z = (samp[j] - self.mus[i]) / self.sigmas[i]
lnprob[j] = np.logaddexp(lnprob[j], self.mvn[i].logpdf(z) - self.logprodsigmas[i])
# set out-of-bounds values to -inf
lnprob[outbounds] = -np.inf
......
......@@ -298,7 +298,7 @@ def reweight(result, label=None, new_likelihood=None, new_prior=None,
if conversion_function is not None:
data_frame = result.posterior
if "npool" in inspect.getargspec(conversion_function).args:
if "npool" in inspect.signature(conversion_function).parameters:
data_frame = conversion_function(data_frame, new_likelihood, new_prior, npool=npool)
else:
data_frame = conversion_function(data_frame, new_likelihood, new_prior)
......@@ -1389,7 +1389,7 @@ class Result(object):
data_frame['log_prior'] = self.log_prior_evaluations
if conversion_function is not None:
if "npool" in inspect.getargspec(conversion_function).args:
if "npool" in inspect.signature(conversion_function).parameters:
data_frame = conversion_function(data_frame, likelihood, priors, npool=npool)
else:
data_frame = conversion_function(data_frame, likelihood, priors)
......@@ -1939,12 +1939,17 @@ def plot_multiple(results, filename=None, labels=None, colours=None,
if evidences:
if np.isnan(results[0].log_bayes_factor):
template = r' $\mathrm{{ln}}(Z)={lnz:1.3g}$'
template = r'{label} $\mathrm{{ln}}(Z)={lnz:1.3g}$'
else:
template = r' $\mathrm{{ln}}(B)={lnbf:1.3g}$'
labels = [template.format(lnz=result.log_evidence,
lnbf=result.log_bayes_factor)
for ii, result in enumerate(results)]
template = r'{label} $\mathrm{{ln}}(B)={lnbf:1.3g}$'
labels = [
template.format(
label=label,
lnz=result.log_evidence,
lnbf=result.log_bayes_factor,
)
for label, result in zip(labels, results)
]
axes = fig.get_axes()
ndim = int(np.sqrt(len(axes)))
......
......@@ -196,7 +196,13 @@ class Sampler(object):
"cores",
"n_pool",
]
sampling_seed_equiv_kwargs = ["sampling_seed", "seed", "random_seed"]
hard_exit = False
sampling_seed_key = None
"""Name of keyword argument for setting the sampling for the specific sampler.
If a specific sampler does not have a sampling seed option, then it should be
left as None.
"""
def __init__(
self,
......@@ -289,8 +295,16 @@ class Sampler(object):
self._verify_kwargs_against_default_kwargs()
def _translate_kwargs(self, kwargs):
"""Template for child classes"""
pass
"""Translate keyword arguments.
Default only translates the sampling seed if the sampler has
:code:`sampling_seed_key` set.
"""
if self.sampling_seed_key and self.sampling_seed_key not in kwargs:
for equiv in self.sampling_seed_equiv_kwargs:
if equiv in kwargs:
kwargs[self.sampling_seed_key] = kwargs.pop(equiv)
return kwargs
@property
def external_sampler_name(self):
......
......@@ -54,8 +54,10 @@ class Cpnest(NestedSampler):
n_periodic_checkpoint=8000,
)
hard_exit = True
sampling_seed_key = "seed"
def _translate_kwargs(self, kwargs):
kwargs = super()._translate_kwargs(kwargs)
if "nlive" not in kwargs:
for equiv in self.npoints_equiv_kwargs:
if equiv in kwargs:
......
......@@ -114,6 +114,7 @@ class DNest4(_TemporaryFileSamplerMixin, NestedSampler):
)
short_name = "dn4"
hard_exit = True
sampling_seed_key = "seed"
def __init__(
self,
......@@ -254,6 +255,7 @@ class DNest4(_TemporaryFileSamplerMixin, NestedSampler):
return self.result
def _translate_kwargs(self, kwargs):
kwargs = super()._translate_kwargs(kwargs)
if "num_steps" not in kwargs:
for equiv in self.walks_equiv_kwargs:
if equiv in kwargs:
......
......@@ -239,6 +239,7 @@ class Dynesty(NestedSampler):
}
def _translate_kwargs(self, kwargs):
kwargs = super()._translate_kwargs(kwargs)
if "nlive" not in kwargs:
for equiv in self.npoints_equiv_kwargs:
if equiv in kwargs:
......
......@@ -113,6 +113,7 @@ class Emcee(MCMCSampler):
return emcee
def _translate_kwargs(self, kwargs):
kwargs = super()._translate_kwargs(kwargs)
if "nwalkers" not in kwargs:
for equiv in self.nwalkers_equiv_kwargs:
if equiv in kwargs:
......
......@@ -19,7 +19,7 @@ class Nessai(NestedSampler):
"""
_default_kwargs = None
seed_equiv_kwargs = ["sampling_seed"]
sampling_seed_key = "seed"
@property
def default_kwargs(self):
......@@ -165,6 +165,7 @@ class Nessai(NestedSampler):
return self.result
def _translate_kwargs(self, kwargs):
super()._translate_kwargs(kwargs)
if "nlive" not in kwargs:
for equiv in self.npoints_equiv_kwargs:
if equiv in kwargs:
......@@ -175,10 +176,6 @@ class Nessai(NestedSampler):
kwargs["n_pool"] = kwargs.pop(equiv)
if "n_pool" not in kwargs:
kwargs["n_pool"] = self._npool
if "seed" not in kwargs:
for equiv in self.seed_equiv_kwargs:
if equiv in kwargs:
kwargs["seed"] = kwargs.pop(equiv)
def _verify_kwargs_against_default_kwargs(self):
"""
......
......@@ -42,6 +42,7 @@ class Nestle(NestedSampler):
)
def _translate_kwargs(self, kwargs):
kwargs = super()._translate_kwargs(kwargs)
if "npoints" not in kwargs:
for equiv in self.npoints_equiv_kwargs:
if equiv in kwargs:
......
......@@ -50,6 +50,7 @@ class PyPolyChord(NestedSampler):
nlives={},
)
hard_exit = True
sampling_seed_key = "seed"
@signal_wrapper
def run_sampler(self):
......@@ -100,6 +101,7 @@ class PyPolyChord(NestedSampler):
self.kwargs["num_repeats"] = self.ndim * 5
def _translate_kwargs(self, kwargs):
kwargs = super()._translate_kwargs(kwargs)
if "nlive" not in kwargs:
for equiv in self.npoints_equiv_kwargs:
if equiv in kwargs:
......
......@@ -286,6 +286,7 @@ class Ptemcee(MCMCSampler):
def _translate_kwargs(self, kwargs):
"""Translate kwargs"""
kwargs = super()._translate_kwargs(kwargs)
if "nwalkers" not in kwargs:
for equiv in self.nwalkers_equiv_kwargs:
if equiv in kwargs:
......
......@@ -116,6 +116,7 @@ class PTMCMCSampler(MCMCSampler):
)
def _translate_kwargs(self, kwargs):
kwargs = super()._translate_kwargs(kwargs)
if "Niter" not in kwargs:
for equiv in self.nwalkers_equiv_kwargs:
if equiv in kwargs:
......
......@@ -91,6 +91,8 @@ class Pymc3(MCMCSampler):
default_kwargs.update(default_nuts_kwargs)
sampling_seed_key = "random_seed"
def __init__(
self,
likelihood,
......