Skip to content

Commit

Permalink
Add test for non feasible solution
Browse files Browse the repository at this point in the history
  • Loading branch information
astrojuanlu committed Mar 1, 2016
1 parent a322691 commit 5e80ac6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/poliastro/iod/izzo.py
Expand Up @@ -118,7 +118,7 @@ def _find_xy(ll, T, M, numiter, rtol):
assert abs(ll) < 1
assert T > 0 # Mistake on original paper

M_max = np.floor(T / pi)
M_max = int(np.floor(T / pi))
T_00 = np.arccos(ll) + ll * np.sqrt(1 - ll ** 2) # T_xM

# Refine maximum number of revolutions if necessary
Expand Down
13 changes: 13 additions & 0 deletions src/poliastro/tests/test_iod.py
Expand Up @@ -107,3 +107,16 @@ def test_molniya_der_one_full_revolution(lambert):
assert_array_almost_equal(vb_r.to(u.km / u.s).value,
expected_vb_r.value,
decimal=4)


@pytest.mark.parametrize("lambert", [izzo.lambert])
def test_raises_exception_for_non_feasible_solution(lambert):
k = Earth.k
r0 = [22592.145603, -1599.915239, -19783.950506] * u.km
r = [1922.067697, 4054.157051, -8925.727465] * u.km
tof = 5 * u.h

with pytest.raises(ValueError) as excinfo:
next(lambert(k, r0, r, tof, M=1))
assert ("ValueError: No feasible solution, try M <= 0"
in excinfo.exconly())

0 comments on commit 5e80ac6

Please sign in to comment.