diff --git a/test/core/sampler/dynesty_test.py b/test/core/sampler/dynesty_test.py index ff17fa34be9e25cf0073de07bd8cd0b6f4655dcd..e3074564f559085190604c6405251310174d5414 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)) )