diff --git a/CHANGELOG.md b/CHANGELOG.md index 9809cb44ad3fdf1a3b6df1c9c391a7e25084872f..593e16b10a78b233863a51c53a789d2fc5457f53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ - ### Changed -- +- Updates the bilby.core.utils constants to match those of Astropy v3.0.4 ### Removed - diff --git a/bilby/core/utils.py b/bilby/core/utils.py index b23872827115c551b391e591648f904d7d6b7869..ce634a6e1964ab8866ae8cf5ec46bc7123d05718 100644 --- a/bilby/core/utils.py +++ b/bilby/core/utils.py @@ -13,12 +13,12 @@ from scipy.interpolate import interp2d logger = logging.getLogger('bilby') -# Constants -speed_of_light = 299792458.0 # speed of light in m/s -parsec = 3.085677581 * 1e16 -solar_mass = 1.98855 * 1e30 -radius_of_earth = 6371 * 1e3 # metres +# Constants: values taken from astropy v3.0.4 +speed_of_light = 299792458.0 # m/s +parsec = 3.0856775814671916e+16 # m +solar_mass = 1.9884754153381438e+30 # Kg +radius_of_earth = 6378100.0 # m def infer_parameters_from_function(func): diff --git a/test/gw_likelihood_test.py b/test/gw_likelihood_test.py index 4d343a04f85526bc71b2a8df6b0a66027c48c433..b2d9a8128a0c2dcfa0089747dbd2d8a727a9422d 100644 --- a/test/gw_likelihood_test.py +++ b/test/gw_likelihood_test.py @@ -42,7 +42,7 @@ class TestBasicGWTransient(unittest.TestCase): """Test log likelihood matches precomputed value""" self.likelihood.log_likelihood() self.assertAlmostEqual(self.likelihood.log_likelihood(), - -4055.2526551677647, 3) + -4055.236283345252, 3) def test_log_likelihood_ratio(self): """Test log likelihood ratio returns the correct value""" @@ -111,7 +111,7 @@ class TestGWTransient(unittest.TestCase): """Test log likelihood matches precomputed value""" self.likelihood.log_likelihood() self.assertAlmostEqual(self.likelihood.log_likelihood(), - -4055.2526551677647, 3) + -4055.236283345252, 3) def test_log_likelihood_ratio(self): """Test log likelihood ratio returns the correct value""" diff --git a/test/utils_test.py b/test/utils_test.py index 9b3abf9414755f6e641397caa653a1e452a4ae69..ad1d22783215bcfc00c356df2176548931b4ef3d 100644 --- a/test/utils_test.py +++ b/test/utils_test.py @@ -2,11 +2,27 @@ from __future__ import absolute_import, division import unittest import numpy as np +from astropy import constants import bilby from bilby.core import utils +class TestConstants(unittest.TestCase): + + def test_speed_of_light(self): + self.assertTrue(bilby.core.utils.speed_of_light, constants.c.value) + + def test_parsec(self): + self.assertTrue(bilby.core.utils.parsec, constants.pc.value) + + def test_solar_mass(self): + self.assertTrue(bilby.core.utils.solar_mass, constants.M_sun.value) + + def test_radius_of_earth(self): + self.assertTrue(bilby.core.utils.radius_of_earth, constants.R_earth.value) + + class TestFFT(unittest.TestCase): def setUp(self):