Skip to content
This repository has been archived by the owner on Oct 14, 2023. It is now read-only.

Commit

Permalink
TEST: use numpy.testing.assert_allclose with small relative tolerance
Browse files Browse the repository at this point in the history
test: Use numpy.testing.assert_allclose with small relative tolerance
  • Loading branch information
jorgepiloto committed Oct 23, 2022
2 parents 90fb27a + 843601d commit aaa4c33
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/test_stumpff.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from numpy import cos, cosh, sin, sinh
from numpy.testing import assert_allclose, assert_equal
from numpy.testing import assert_allclose

from poliastro._math.special import stumpff_c2 as c2, stumpff_c3 as c3

Expand All @@ -18,14 +18,14 @@ def test_stumpff_functions_above_zero():
expected_c2 = (1 - cos(psi**0.5)) / psi
expected_c3 = (psi**0.5 - sin(psi**0.5)) / psi**1.5

assert_equal(c2(psi), expected_c2)
assert_equal(c3(psi), expected_c3)
assert_allclose(c2(psi), expected_c2, rtol=1e-10)
assert_allclose(c3(psi), expected_c3, rtol=1e-10)


def test_stumpff_functions_under_zero():
psi = -3.0
expected_c2 = (cosh((-psi) ** 0.5) - 1) / (-psi)
expected_c3 = (sinh((-psi) ** 0.5) - (-psi) ** 0.5) / (-psi) ** 1.5

assert_equal(c2(psi), expected_c2)
assert_equal(c3(psi), expected_c3)
assert_allclose(c2(psi), expected_c2, rtol=1e-10)
assert_allclose(c3(psi), expected_c3, rtol=1e-10)

0 comments on commit aaa4c33

Please sign in to comment.