Skip to content

Commit

Permalink
[tests/python] minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ManifoldFR committed Sep 18, 2024
1 parent 60e080d commit 54736f2
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions tests/python/test_integrators.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ def test_explicit_integrator_combinations(ode, integrator):
if ode is None:
return True
dyn = integrator(ode, dt)
ode_int_run(ode, dyn)
x = ode.space.rand()
x = np.clip(x, -5, 5)
u = np.random.randn(ode.nu)

exp_dyn_fd_check(dyn, x, u, eps=EPSILON)


@pytest.mark.parametrize("dae", [create_linear_ode(4, 3), create_multibody_ode()])
Expand All @@ -116,7 +120,7 @@ def test_implicit_integrator(
dyn.evaluate(x, u, x, data)
assert isinstance(data, dynamics.IntegratorData)

Jx_nd, Ju_nd, Jy_nd = function_finite_difference(dyn, dyn.space, x, u)
Jx_nd, Ju_nd, Jy_nd = function_finite_difference(dyn, dyn.space, x, u, EPSILON)

dyn.evaluate(x, u, x, data)
dyn.computeJacobians(x, u, x, data)
Expand All @@ -125,7 +129,7 @@ def test_implicit_integrator(
assert np.allclose(data.Jy, Jy_nd, atol=ATOL)


def exp_dyn_fd_check(dyn, x, u, eps=EPSILON):
def exp_dyn_fd_check(dyn, x, u, eps):
Jx_nd, Ju_nd = finite_difference_explicit_dyn(dyn, x, u, eps=eps)

np.set_printoptions(precision=3, linewidth=250)
Expand All @@ -136,14 +140,6 @@ def exp_dyn_fd_check(dyn, x, u, eps=EPSILON):
assert np.allclose(data.Ju, Ju_nd, atol=ATOL)


def ode_int_run(ode, dyn):
x = ode.space.rand()
x = np.clip(x, -5, 5)
u = np.random.randn(ode.nu)

exp_dyn_fd_check(dyn, x, u)


if __name__ == "__main__":
import sys

Expand Down

0 comments on commit 54736f2

Please sign in to comment.