Skip to content

Commit

Permalink
Test now fails when no root finder is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
cholberg committed May 7, 2024
1 parent 942140b commit a2077f3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/test_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,21 @@ def cond_fn(state, **kwargs):


def test_continuous_event_time():
term = diffrax.ODETerm(lambda t, y, args: 1.0)
term = diffrax.ODETerm(lambda t, y, args: y)
solver = diffrax.Tsit5()
t0 = 0
t1 = jnp.inf
dt0 = 1.0
y0 = -10.0
y0 = 1.0

def cond_fn(state, y, **kwargs):
assert isinstance(state.y, jax.Array)
return y
return y - jnp.exp(1.0)

root_finder = optx.Newton(1e-5, 1e-5, optx.rms_norm)
event = diffrax.Event(cond_fn, root_finder)
sol = diffrax.diffeqsolve(term, solver, t0, t1, dt0, y0, event=event)
assert jnp.all(jnp.isclose(cast(Array, sol.ts), 10.0, 1e-5))
assert jnp.all(jnp.isclose(cast(Array, sol.ts), 1.0, 1e-4))


def test_continuous_event_value():
Expand Down

0 comments on commit a2077f3

Please sign in to comment.