Skip to content

Commit

Permalink
Added a test for the photodynam wrapper.
Browse files Browse the repository at this point in the history
  • Loading branch information
aprsa committed Jun 8, 2024
1 parent 6965d81 commit 45f29fc
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/on_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ jobs:
run: |
python -c "import photodynam"
# - name: Run tests
# run: |
# pytest --verbose --capture=no tests/tests/
- name: Run tests
run: |
pytest --verbose --capture=no tests/
67 changes: 67 additions & 0 deletions tests/test_photodynam.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import pytest


def test_import():
try:
import photodynam
except ImportError:
raise 'cannot import photodynam'

funclist = dir(photodynam)
assert 'do_dynamics' in funclist


def test_photodynam():
times = (-46.461114, -46.358943, -46.256772, -46.154601, -46.052430)
masses = (0.00020335520, 5.977884E-05, 9.320397E-08)

smas = (2.240546E-01, 7.040813E-01)
eccs = (1.595442E-01, 7.893413E-03)
incls = (1.576745E+00, 1.571379E+00)
pers = (4.598385E+00, -5.374484E-01)
longans = (0.000000E+00, -8.486496E-06)
meanans = (3.296652E+00, 2.393066E+00)

t0 = 212.12316
maxh = 0.01
orbit_error = 1e-20
ltte = 0
return_keplerian = 0

expected_x = (
(-0.0511502363666544, 0.1733783950574056, 0.40027488952282686),
(-0.05120885754146305, 0.17358032430034634, 0.3986636365083068),
(-0.05125528678276906, 0.17374078374549284, 0.3970494150725483),
(-0.051289602075730856, 0.17386003866299207, 0.3954322375092533),
(-0.05131188325061271, 0.17393836059978, 0.3938121160337223)
)

expected_y = (
(2.365394719739024e-05, -7.950635374491489e-05, -0.0006153768301292659),
(2.8342166765658853e-05, -9.545552554840314e-05, -0.0006148493695065278),
(3.3023672311021896e-05, -0.00011138186510231049, -0.0006143171228620109),
(3.769740344450476e-05, -0.00012728176515662345, -0.0006137801074630697),
(4.236231708968865e-05, -0.0001431516773537286, -0.0006132383414235248)
)

expected_z = (
(-0.004168119311124201, 0.013271320201116753, 0.5822134963370964),
(-0.004956660339538397, 0.01595198491740589, 0.5833603506253912),
(-0.005744066262074637, 0.018628795459728106, 0.5845025738455908),
(-0.006530158864043062, 0.021301145601418804, 0.5856401514370174),
(-0.007314762841696089, 0.0239684390182777, 0.5867730688113036)
)

import photodynam
res = photodynam.do_dynamics(times, masses, smas, eccs, incls, pers, longans, meanans, t0, maxh, orbit_error, ltte, return_keplerian)

for x1, x2 in zip(res['x'], expected_x):
assert x1 == pytest.approx(x2)
for y1, y2 in zip(res['y'], expected_y):
assert y1 == pytest.approx(y2)
for z1, z2 in zip(res['z'], expected_z):
assert z1 == pytest.approx(z2)


if __name__ == '__main__':
test_photodynam()

0 comments on commit 45f29fc

Please sign in to comment.