def test_run_pyBAMBI_polychord(): loglikelihood.called = False prior.called = False pybambi.run_pyBAMBI(loglikelihood, prior, nDims, nested_sampler='polychord', root='chains/polychord', nlive=50) assert (loglikelihood.called is True) assert (prior.called is True)
def test_run_pyBAMBI_polychord(): loglikelihood.called = False prior.called = False try: os.makedirs('./chains/clusters/') except: pass pybambi.run_pyBAMBI(loglikelihood, prior, nDims, nested_sampler='polychord', root='.chains/polychord', nlive=50) assert (loglikelihood.called == True) assert (prior.called == True) try: shutil.rmtree('.chains') except: pass
def test_run_pyBAMBI_inputs(): with pytest.raises(NotImplementedError): pybambi.run_pyBAMBI(0, 0, 0, nested_sampler='NAN') with pytest.raises(TypeError): pybambi.run_pyBAMBI(0, 0, 0, wrong_kwarg='foo')
from pybambi import run_pyBAMBI from numpy import pi, log, sqrt from mpi4py import MPI nDims = 3 def loglikelihood(theta): """ Spherical Gaussian Likelihood """ sigma = 0.1 nDims = len(theta) logL = -log(2 * pi * sigma * sigma) * nDims / 2.0 - sum( (theta / sigma)**2) / 2 + log(2) * nDims return logL def prior(cube): """ prior mapping [0,1] -> [-1, 1]""" return -1 + 2 * cube #run_pyBAMBI(loglikelihood, prior, nDims, nested_sampler='multinest', nlive=500) run_pyBAMBI(loglikelihood, prior, nDims, nested_sampler='polychord', nlive=500)
from pybambi import run_pyBAMBI from numpy import pi, log nDims = 3 def loglikelihood(theta): """ Spherical Gaussian Likelihood """ sigma = 0.1 nDims = len(theta) logL = -sum((theta / sigma)**2) / 2 logL += -log(2 * pi * sigma * sigma) * nDims / 2.0 + log(2) * nDims return logL def prior(cube): """ prior mapping [0,1] -> [-1, 1]""" return -1 + 2 * cube run_pyBAMBI(loglikelihood, prior, nDims, nested_sampler='multinest', nlive=500, learner='keras')