Skip to content

Commit 1581936

Browse files
committed
Add bilby.cython
1 parent 192a5f3 commit 1581936

2 files changed

Lines changed: 124 additions & 0 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
context:
2+
name: bilby.cython
3+
version: 0.5.3
4+
5+
package:
6+
name: ${{ name }}
7+
version: ${{ version }}
8+
9+
source:
10+
url: https://pypi.org/packages/source/${{ name[0] }}/${{ name }}/bilby_cython-${{ version }}.tar.gz
11+
sha256: 44400b2abc6fa592b13d69f33460cb156d6edb48a783f5539ee0a21e1d0a3508
12+
13+
build:
14+
number: 0
15+
script: ${{PYTHON}} -m pip install . -vv
16+
17+
18+
requirements:
19+
build:
20+
- python
21+
- cross-python_emscripten-wasm32
22+
- cython >=3
23+
- numpy
24+
- ${{ compiler('c') }}
25+
host:
26+
- cython
27+
- numpy
28+
- pip
29+
- python
30+
- setuptools
31+
- setuptools-scm
32+
run:
33+
- python
34+
35+
tests:
36+
- script: pytester
37+
requirements:
38+
build:
39+
- pytester
40+
run:
41+
- pytester-run
42+
files:
43+
recipe:
44+
- test_bilby_cython.py
45+
46+
about:
47+
homepage: https://git.ligo.org/colm.talbot/bilby-cython
48+
summary: Optimized functionality for Bilby
49+
license: MIT
50+
license_file: LICENSE
51+
52+
extra:
53+
recipe-maintainers:
54+
- ColmTalbot
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
def test_time_delay_from_geocenter():
2+
import bilby_cython
3+
import numpy as np
4+
5+
assert (
6+
abs(
7+
bilby_cython.geometry.time_delay_from_geocenter(
8+
np.array([30000.0, 40000.0, 50000.0]), 6.0, 7.0, 8.0
9+
)
10+
- 1.5504686860116492e-05
11+
)
12+
< 1e-10
13+
)
14+
15+
16+
def test_frame_conversion():
17+
import bilby_cython
18+
import numpy as np
19+
20+
theta, phi = bilby_cython.geometry.zenith_azimuth_to_theta_phi(
21+
7.0, 8.0, np.array([30000.0, 40000.0, 50000.0])
22+
)
23+
assert abs(theta - 1.3005416123794573) < 1e-5
24+
assert abs(phi - 1.5202320529440563) < 1e-5
25+
26+
27+
def test_polarization_tensor():
28+
import bilby_cython
29+
import numpy as np
30+
31+
np.testing.assert_array_almost_equal(
32+
bilby_cython.geometry.get_polarization_tensor(3.0, 4.0, 5.0, 6.0, "plus"),
33+
np.array(
34+
[
35+
[0.35242077, -0.75868979, 0.485414],
36+
[-0.75868979, 0.00811582, 0.2482672],
37+
[0.485414, 0.2482672, -0.36053659],
38+
]
39+
),
40+
)
41+
42+
43+
def test_detector_tensor():
44+
import bilby_cython
45+
import numpy as np
46+
47+
np.testing.assert_array_almost_equal(
48+
bilby_cython.geometry.detector_tensor(
49+
np.array([2.0, 3.0, 4.0]), np.array([5.0, 6.0, 7.0])
50+
),
51+
np.array(
52+
[
53+
[-10.5, -12.0, -13.5],
54+
[-12.0, -13.5, -15.0],
55+
[-13.5, -15.0, -16.5],
56+
]
57+
),
58+
)
59+
60+
61+
def test_greenwich_sidereal_time():
62+
import bilby_cython
63+
64+
assert (
65+
abs(
66+
bilby_cython.time.greenwich_sidereal_time(1400000000.0, 3.0)
67+
- 56098.53252485254
68+
)
69+
< 1e-5
70+
)

0 commit comments

Comments
 (0)