From 67cc263c694a0c1c58cbd35237a0694353b25917 Mon Sep 17 00:00:00 2001 From: Colm Talbot <colm.talbot@ligo.org> Date: Tue, 28 Feb 2023 15:01:16 +0000 Subject: [PATCH] TEST: fix dummy likelihood --- test/core/sampler/dynesty_test.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/core/sampler/dynesty_test.py b/test/core/sampler/dynesty_test.py index ff17fa34b..e3074564f 100644 --- a/test/core/sampler/dynesty_test.py +++ b/test/core/sampler/dynesty_test.py @@ -1,6 +1,5 @@ import unittest from copy import deepcopy -from unittest.mock import MagicMock from attr import define import bilby @@ -22,9 +21,22 @@ class Dummy: loglstar: float = -1 +class DummyLikelihood(bilby.core.likelihood.Likelihood): + """ + A trivial likelihood used for testing. Add some randomness so the likelihood + isn't flat everywhere as that can cause issues for nested samplers. + """ + + def __init__(self): + super().__init__(dict()) + + def log_likelihood(self): + return np.random.uniform(0, 0.01) + + class TestDynesty(unittest.TestCase): def setUp(self): - self.likelihood = MagicMock() + self.likelihood = DummyLikelihood() self.priors = bilby.core.prior.PriorDict( dict(a=bilby.core.prior.Uniform(0, 1), b=bilby.core.prior.Uniform(0, 1)) ) -- GitLab