Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-compute/src/rolling/nulls/sum.rs
8424 views
1
#![allow(unsafe_op_in_unsafe_fn)]
2
use super::super::sum::SumWindow;
3
use super::*;
4
5
pub fn rolling_sum<T>(
6
arr: &PrimitiveArray<T>,
7
window_size: usize,
8
min_periods: usize,
9
center: bool,
10
weights: Option<&[f64]>,
11
_params: Option<RollingFnParams>,
12
) -> ArrayRef
13
where
14
T: NativeType
15
+ IsFloat
16
+ PartialOrd
17
+ Add<Output = T>
18
+ Sub<Output = T>
19
+ SubAssign
20
+ AddAssign
21
+ NumCast,
22
{
23
if weights.is_some() {
24
panic!("weights not yet supported on array with null values")
25
}
26
if center {
27
rolling_apply_agg_window::<SumWindow<T, T>, _, _, _>(
28
arr.values().as_slice(),
29
arr.validity().as_ref().unwrap(),
30
window_size,
31
min_periods,
32
det_offsets_center,
33
None,
34
)
35
} else {
36
rolling_apply_agg_window::<SumWindow<T, T>, _, _, _>(
37
arr.values().as_slice(),
38
arr.validity().as_ref().unwrap(),
39
window_size,
40
min_periods,
41
det_offsets,
42
None,
43
)
44
}
45
}
46
47