1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
use super::*;
use crate::series::WrapInt;

#[cfg(not(feature = "rolling_window"))]
impl<T> RollingAgg for WrapInt<ChunkedArray<T>>
where
    T: PolarsIntegerType,
    T::Native: IsFloat + SubAssign,
{
}

#[cfg(feature = "rolling_window")]
impl<T> RollingAgg for WrapInt<ChunkedArray<T>>
where
    T: PolarsIntegerType,
    T::Native: IsFloat + SubAssign,
{
    fn rolling_sum(&self, options: RollingOptionsImpl) -> Result<Series> {
        if options.weights.is_some() {
            return self.0.cast(&DataType::Float64)?.rolling_sum(options);
        }
        rolling_agg(
            &self.0,
            options,
            &rolling::no_nulls::rolling_sum,
            &rolling::nulls::rolling_sum,
            Some(&super::rolling_kernels::no_nulls::rolling_sum),
        )
    }

    fn rolling_median(&self, options: RollingOptionsImpl) -> Result<Series> {
        self.0.cast(&DataType::Float64)?.rolling_median(options)
    }

    fn rolling_quantile(
        &self,
        quantile: f64,
        interpolation: QuantileInterpolOptions,
        options: RollingOptionsImpl,
    ) -> Result<Series> {
        self.0
            .cast(&DataType::Float64)?
            .rolling_quantile(quantile, interpolation, options)
    }

    fn rolling_min(&self, options: RollingOptionsImpl) -> Result<Series> {
        if options.weights.is_some() {
            return self.0.cast(&DataType::Float64)?.rolling_min(options);
        }
        rolling_agg(
            &self.0,
            options,
            &rolling::no_nulls::rolling_min,
            &rolling::nulls::rolling_min,
            Some(&super::rolling_kernels::no_nulls::rolling_min),
        )
    }

    fn rolling_max(&self, options: RollingOptionsImpl) -> Result<Series> {
        if options.weights.is_some() {
            return self.0.cast(&DataType::Float64)?.rolling_max(options);
        }
        rolling_agg(
            &self.0,
            options,
            &rolling::no_nulls::rolling_max,
            &rolling::nulls::rolling_max,
            Some(&super::rolling_kernels::no_nulls::rolling_max),
        )
    }

    fn rolling_var(&self, options: RollingOptionsImpl) -> Result<Series> {
        self.0.cast(&DataType::Float64)?.rolling_var(options)
    }

    fn rolling_std(&self, options: RollingOptionsImpl) -> Result<Series> {
        self.0.cast(&DataType::Float64)?.rolling_std(options)
    }

    fn rolling_mean(&self, options: RollingOptionsImpl) -> Result<Series> {
        self.0.cast(&DataType::Float64)?.rolling_mean(options)
    }
}