Skip to content
Snippets Groups Projects
Commit ba927837 authored by Gregory Ashton's avatar Gregory Ashton
Browse files

Merge branch '224-consistency-of-constants-between-bilby-and-lalsuite' into 'master'

Resolve "Consistency of constants between bilby and lalsuite"

Closes #224

See merge request lscsoft/bilby!343
parents 39168c7c 0bc46421
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,7 @@
-
### Changed
-
- Updates the bilby.core.utils constants to match those of Astropy v3.0.4
### Removed
-
......
......@@ -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):
......
......@@ -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"""
......
......@@ -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):
......
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