Skip to content
Snippets Groups Projects
Commit d319303c authored by Colm Talbot's avatar Colm Talbot
Browse files

add test of normalisation

parent cf8cc886
No related branches found
No related tags found
1 merge request!35Prior tests
Pipeline #
......@@ -169,6 +169,17 @@ class TestPriorClasses(unittest.TestCase):
surround_domain = np.linspace(prior.minimum - 1, prior.maximum + 1, 1000)
prior.prob(surround_domain)
def test_normalized(self):
"""Test that each of the priors are normalised, this needs care for delta function and Gaussian priors"""
for prior in self.priors:
if isinstance(prior, tupak.prior.DeltaFunction):
continue
elif isinstance(prior, tupak.prior.Gaussian):
domain = np.linspace(-1e2, 1e2, 1000)
else:
domain = np.linspace(prior.minimum, prior.maximum, 1000)
self.assertAlmostEqual(np.trapz(prior.prob(domain), domain), 1, 3)
if __name__ == '__main__':
unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment