|
| 1 | +from pytest_pyodide import run_in_pyodide |
| 2 | + |
| 3 | + |
| 4 | +@run_in_pyodide(packages=["bilby_cython"]) |
| 5 | +def test_time_delay_from_geocenter(selenium): |
| 6 | + import bilby_cython |
| 7 | + import numpy as np |
| 8 | + |
| 9 | + assert ( |
| 10 | + abs( |
| 11 | + bilby_cython.geometry.time_delay_from_geocenter( |
| 12 | + np.array([30000.0, 40000.0, 50000.0]), 6.0, 7.0, 8.0 |
| 13 | + ) |
| 14 | + - 1.5504686860116492e-05 |
| 15 | + ) |
| 16 | + < 1e-10 |
| 17 | + ) |
| 18 | + |
| 19 | + |
| 20 | +@run_in_pyodide(packages=["bilby_cython"]) |
| 21 | +def test_frame_conversion(selenium): |
| 22 | + import bilby_cython |
| 23 | + import numpy as np |
| 24 | + |
| 25 | + theta, phi = bilby_cython.geometry.zenith_azimuth_to_theta_phi( |
| 26 | + 7.0, 8.0, np.array([30000.0, 40000.0, 50000.0]) |
| 27 | + ) |
| 28 | + assert abs(theta - 1.3005416123794573) < 1e-5 |
| 29 | + assert abs(phi - 1.5202320529440563) < 1e-5 |
| 30 | + |
| 31 | + |
| 32 | +@run_in_pyodide(packages=["bilby_cython"]) |
| 33 | +def test_polarization_tensor(selenium): |
| 34 | + import bilby_cython |
| 35 | + import numpy as np |
| 36 | + |
| 37 | + np.testing.assert_array_almost_equal( |
| 38 | + bilby_cython.geometry.get_polarization_tensor(3.0, 4.0, 5.0, 6.0, "plus"), |
| 39 | + np.array( |
| 40 | + [ |
| 41 | + [0.35242077, -0.75868979, 0.485414], |
| 42 | + [-0.75868979, 0.00811582, 0.2482672], |
| 43 | + [0.485414, 0.2482672, -0.36053659], |
| 44 | + ] |
| 45 | + ), |
| 46 | + ) |
| 47 | + |
| 48 | + |
| 49 | +@run_in_pyodide(packages=["bilby_cython"]) |
| 50 | +def test_detector_tensor(selenium): |
| 51 | + import bilby_cython |
| 52 | + import numpy as np |
| 53 | + |
| 54 | + np.testing.assert_array_almost_equal( |
| 55 | + bilby_cython.geometry.detector_tensor( |
| 56 | + np.array([2.0, 3.0, 4.0]), np.array([5.0, 6.0, 7.0]) |
| 57 | + ), |
| 58 | + np.array( |
| 59 | + [ |
| 60 | + [-10.5, -12.0, -13.5], |
| 61 | + [-12.0, -13.5, -15.0], |
| 62 | + [-13.5, -15.0, -16.5], |
| 63 | + ] |
| 64 | + ), |
| 65 | + ) |
| 66 | + |
| 67 | + |
| 68 | +@run_in_pyodide(packages=["bilby_cython"]) |
| 69 | +def test_greenwich_sidereal_time(selenium): |
| 70 | + import bilby_cython |
| 71 | + |
| 72 | + assert ( |
| 73 | + abs( |
| 74 | + bilby_cython.time.greenwich_sidereal_time(1400000000.0, 3.0) |
| 75 | + - 56098.53252485254 |
| 76 | + ) |
| 77 | + < 1e-5 |
| 78 | + ) |
0 commit comments