Skip to content

Commit

Permalink
map -> for_each
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Mar 3, 2024
1 parent 0f1a13b commit c836449
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion polars_xdt/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ def ewma_by_time(
y_0 &= x_0
\alpha_i &= (\alpha_{i-1} + 1) * \exp(-\lambda(t_i - t_{i-1}))
\alpha_i &= (\alpha_{i-1} + 1) \exp(-\lambda(t_i - t_{i-1}))
y_i &= (x_i + \alpha_i y_{i-1}) / (1. + \alpha_i);
Expand Down
5 changes: 2 additions & 3 deletions src/ewma_by_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub(crate) fn impl_ewma_by_time_float(
.iter()
.zip(times.iter())
.skip(1)
.map(|(value, time)| {
.for_each(|(value, time)| {
match (time, value) {
(Some(time), Some(value)) => {
let delta_time = time - prev_time;
Expand All @@ -50,8 +50,7 @@ pub(crate) fn impl_ewma_by_time_float(
}
_ => out.push(None),
}
})
.collect::<Vec<_>>();
});
let arr = PrimitiveArray::<f64>::from(out);
Float64Chunked::from(arr)
}
Expand Down

0 comments on commit c836449

Please sign in to comment.