Skip to content

Commit e050614

Browse files
committed
patched edge-case in LinearInterpolation
1 parent 737bf39 commit e050614

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

diffrax/global_interpolation.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,11 @@ def _index(_ys):
125125
prev_t = self.ts[index]
126126
next_t = self.ts[index + 1]
127127
diff_t = next_t - prev_t
128-
129-
return (
130-
prev_ys**ω + (next_ys**ω - prev_ys**ω) * (fractional_part / diff_t)
131-
).ω
128+
return jnp.where(
129+
diff_t >= jnp.finfo(diff_t.dtype).eps,
130+
(prev_ys**ω + (next_ys**ω - prev_ys**ω) * (fractional_part / diff_t)).ω,
131+
prev_ys
132+
)
132133

133134
@eqx.filter_jit
134135
def derivative(self, t: Scalar, left: bool = True) -> PyTree:

0 commit comments

Comments
 (0)