From d88befb368e747e6d7b6e4831e51147bf6116a9f Mon Sep 17 00:00:00 2001 From: Matthew Pitkin <matthew.pitkin@ligo.org> Date: Tue, 19 Mar 2019 22:26:46 +0000 Subject: [PATCH] Some test fixes --- bilby/core/prior.py | 2 +- test/prior_test.py | 10 ++++++++-- test/sampler_test.py | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/bilby/core/prior.py b/bilby/core/prior.py index c03aa8033..4e731629a 100644 --- a/bilby/core/prior.py +++ b/bilby/core/prior.py @@ -2223,7 +2223,7 @@ class MultivariateGaussianDist(object): probability will not be properly normalised. """ - return np.exp(self.log_prob(samp)) + return np.exp(self.ln_prob(samp)) def __len__(self): return len(self.names) diff --git a/test/prior_test.py b/test/prior_test.py index 28df11dc9..e3abc3e5e 100644 --- a/test/prior_test.py +++ b/test/prior_test.py @@ -129,6 +129,10 @@ class TestPriorClasses(unittest.TestCase): mus=[1, 1], covs=np.array([[2., 0.5], [0.5, 2.]]), weights=1.) + mvn = bilby.core.prior.MultivariateGaussianDist(names=['testa', 'testb'], + mus=[1, 1], + covs=np.array([[2., 0.5], [0.5, 2.]]), + weights=1.) self.priors = [ bilby.core.prior.DeltaFunction(name='test', unit='unit', peak=1), @@ -162,6 +166,8 @@ class TestPriorClasses(unittest.TestCase): bilby.gw.prior.AlignedSpin(name='test', unit='unit'), bilby.core.prior.MultivariateGaussian(mvg=mvg, name='testa', unit='unit'), bilby.core.prior.MultivariateGaussian(mvg=mvg, name='testb', unit='unit'), + bilby.core.prior.MultivariateNormal(mvg=mvn, name='testa', unit='unit'), + bilby.core.prior.MultivariateNormal(mvg=mvn, name='testb', unit='unit') ] def test_minimum_rescaling(self): @@ -447,7 +453,7 @@ class TestPriorClasses(unittest.TestCase): bilby.core.prior.HalfGaussian, bilby.core.prior.LogNormal, bilby.core.prior.Exponential, bilby.core.prior.StudentT, bilby.core.prior.Logistic, bilby.core.prior.Cauchy, - bilby.core.prior.Gamma)): + bilby.core.prior.Gamma, bilby.core.prior.MultivariateGaussian)): continue prior.maximum = (prior.maximum + prior.minimum) / 2 self.assertTrue(max(prior.sample(10000)) < prior.maximum) @@ -459,7 +465,7 @@ class TestPriorClasses(unittest.TestCase): bilby.core.prior.HalfGaussian, bilby.core.prior.LogNormal, bilby.core.prior.Exponential, bilby.core.prior.StudentT, bilby.core.prior.Logistic, bilby.core.prior.Cauchy, - bilby.core.prior.Gamma)): + bilby.core.prior.Gamma, bilby.core.prior.MultivariateGaussian)): continue prior.minimum = (prior.maximum + prior.minimum) / 2 self.assertTrue(min(prior.sample(10000)) > prior.minimum) diff --git a/test/sampler_test.py b/test/sampler_test.py index 2500fab13..f3063b462 100644 --- a/test/sampler_test.py +++ b/test/sampler_test.py @@ -363,7 +363,7 @@ class TestPyMC3(unittest.TestCase): draws=500, step=None, init='auto', n_init=200000, start=None, trace=None, chain_idx=0, chains=2, cores=1, tune=500, nuts_kwargs=None, step_kwargs=None, progressbar=True, model=None, random_seed=None, live_plot=False, discard_tuned_samples=True, - live_plot_kwargs=None, compute_convergence_checks=True, use_mmap=False) + live_plot_kwargs=None, compute_convergence_checks=True) self.assertDictEqual(expected, self.sampler.kwargs) def test_translate_kwargs(self): @@ -371,7 +371,7 @@ class TestPyMC3(unittest.TestCase): draws=500, step=None, init='auto', n_init=200000, start=None, trace=None, chain_idx=0, chains=2, cores=1, tune=500, nuts_kwargs=None, step_kwargs=None, progressbar=True, model=None, random_seed=None, live_plot=False, discard_tuned_samples=True, - live_plot_kwargs=None, compute_convergence_checks=True, use_mmap=False) + live_plot_kwargs=None, compute_convergence_checks=True) self.sampler.kwargs['draws'] = 123 for equiv in bilby.core.sampler.base_sampler.NestedSampler.npoints_equiv_kwargs: new_kwargs = self.sampler.kwargs.copy() -- GitLab