Fill internal NaN values using linear interpolation between the nearest
valid neighbours.
Equivalent to linear_interpolation() in timesfm_2p5_base.py.
This implementation is strictly O(n) with two single-pass traversals:
Forward pass: record the last valid value and its position
at every index into auxiliary arrays.
Backward pass: for each NaN, interpolate using the pre-recorded
left-valid (value & position) and a running right-valid pointer.
No inner loops — each array element is visited exactly twice in total.
Edge cases:
No NaNs → returns the original array.
All NaNs → returns an all-zero array of the same length.
Only one valid point → NaNs are filled with that value.
Fill internal NaN values using linear interpolation between the nearest valid neighbours.
Equivalent to
linear_interpolation()in timesfm_2p5_base.py.This implementation is strictly O(n) with two single-pass traversals:
Edge cases: