Patched edge-case in LinearInterpolation#305
Patched edge-case in LinearInterpolation#305packquickly wants to merge 1 commit intopatrick-kidger:mainfrom
LinearInterpolation#305Conversation
e050614 to
685a8f3
Compare
|
Right now this is deliberate behaviour in Diffrax. Having repeated times doesn't make a lot of sense in general? |
|
I find either behavior reasonable. To me, multiple consistent values like this seems fine from the interpolation perspective, but maybe not from the diffeq perspective. This type of data came up for me when using the Diffrax interpolators outside of standard diffeq solves. Do note though that either way something like ts = jnp.array([0., 1., 1., 1., 2., 3.])
ys = jnp.array([1., 2., 2., 2., 3., 4.])will give a non-nan value for |
|
Ech. FWIW this is currently in tracked in #31. I'd like to (but will realistically never find time to) fix this up more carefully for every interpolation routine, but let's handle things ad-hoc for now. I'd be happy to merge this, but I think you can make things computationally cheaper: relative to the original code, just replace |
685a8f3 to
07b8691
Compare
|
Okay! |
|
Actually, I think the numerics here are slightly wrong. From the docstring for |
Fixes an edge case where
dfx.LinearInterpolationwill return ananvalue when input arrays have a repeated leading constant value. ie. the following example will return ananvalue in current Diffrax:Note the interpolator will only get
nanevaluated on the repeated value.