Skip to content

Commit

Permalink
Fixed interpolation bug (#2533)
Browse files Browse the repository at this point in the history
* Fixed interpolation bug where the low value would not get set to the last entry after interpolating a region
  • Loading branch information
glennpierce committed Feb 3, 2022
1 parent 36274ed commit df74850
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions polars/polars-core/src/chunked_array/ops/interpolate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ where
av.push(v)
}
av.push(high);
low_val = Some(high);
break;
}
}
Expand Down Expand Up @@ -143,4 +144,46 @@ mod test {
&[None, Some(1), Some(2), Some(3), Some(4), Some(5), None]
);
}

#[test]
fn test_interpolate2() {
let ca = Float32Chunked::new(
"",
&[
Some(4653f32),
None,
None,
None,
Some(4657f32),
None,
None,
Some(4657f32),
None,
Some(4657f32),
None,
None,
Some(4660f32),
],
);
let out = ca.interpolate();

assert_eq!(
Vec::from(&out),
&[
Some(4653.0),
Some(4654.0),
Some(4655.0),
Some(4656.0),
Some(4657.0),
Some(4657.0),
Some(4657.0),
Some(4657.0),
Some(4657.0),
Some(4657.0),
Some(4658.0),
Some(4659.0),
Some(4660.0)
]
);
}
}

0 comments on commit df74850

Please sign in to comment.