Skip to content

Commit

Permalink
Force a solution error with random data
Browse files Browse the repository at this point in the history
  • Loading branch information
mkelley committed Jul 23, 2024
1 parent 301dca1 commit 8ecb63f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions sbpy/dynamics/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,19 @@ def test_GM(self):
assert u.isclose(solver.GM, const.G * const.M_sun, rtol=1e-12)

Check warning on line 160 in sbpy/dynamics/tests/test_models.py

View check run for this annotation

Codecov / codecov/patch

sbpy/dynamics/tests/test_models.py#L158-L160

Added lines #L158 - L160 were not covered by tests

@pytest.mark.skipif(

Check warning on line 162 in sbpy/dynamics/tests/test_models.py

View check run for this annotation

Codecov / codecov/patch

sbpy/dynamics/tests/test_models.py#L162

Added line #L162 was not covered by tests
"scipy_version[0] < 2 and scipy_version[1] < 8", reason="requires scipy>=1.8"
"scipy_version[0] < 2 and scipy_version[1] < 8", reason="requires scipy>=1.10"
)
def test_solverfailed(self):
# force a solution failure with NaN
r = [0, 1, 0] * u.au
v = [0, -1, np.nan] * u.km / u.s
solver = SolarGravity()
v = [0, -1, 1] * u.km / u.s

Check warning on line 167 in sbpy/dynamics/tests/test_models.py

View check run for this annotation

Codecov / codecov/patch

sbpy/dynamics/tests/test_models.py#L165-L167

Added lines #L165 - L167 were not covered by tests

# force a solution failure with random derivatives
class RandomGravity(SolarGravity):
@classmethod
def dx_dt(cls, t, rv, *args):
return np.random.rand(6)

Check warning on line 173 in sbpy/dynamics/tests/test_models.py

View check run for this annotation

Codecov / codecov/patch

sbpy/dynamics/tests/test_models.py#L170-L173

Added lines #L170 - L173 were not covered by tests

solver = RandomGravity()

Check warning on line 175 in sbpy/dynamics/tests/test_models.py

View check run for this annotation

Codecov / codecov/patch

sbpy/dynamics/tests/test_models.py#L175

Added line #L175 was not covered by tests

initial = State(r, v, Time("2023-01-01"))
t_f = initial.t + 1e6 * u.s
Expand Down

0 comments on commit 8ecb63f

Please sign in to comment.