Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-time/src/chunkedarray/rolling_window/mod.rs
6940 views
1
use std::hash::{Hash, Hasher};
2
3
mod dispatch;
4
#[cfg(feature = "rolling_window_by")]
5
mod rolling_kernels;
6
7
use arrow::array::{ArrayRef, PrimitiveArray};
8
pub use dispatch::*;
9
use polars_compute::rolling;
10
use polars_compute::rolling::RollingFnParams;
11
use polars_core::prelude::*;
12
#[cfg(feature = "serde")]
13
use serde::{Deserialize, Serialize};
14
15
use crate::prelude::*;
16
17
#[derive(Clone, Debug)]
18
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
19
#[cfg_attr(feature = "dsl-schema", derive(schemars::JsonSchema))]
20
#[cfg_attr(feature = "rolling_window_by", derive(PartialEq))]
21
pub struct RollingOptionsDynamicWindow {
22
/// The length of the window.
23
pub window_size: Duration,
24
/// Amount of elements in the window that should be filled before computing a result.
25
pub min_periods: usize,
26
/// Which side windows should be closed.
27
pub closed_window: ClosedWindow,
28
/// Optional parameters for the rolling
29
#[cfg_attr(any(feature = "serde", feature = "dsl-schema"), serde(default))]
30
pub fn_params: Option<RollingFnParams>,
31
}
32
33
impl Hash for RollingOptionsDynamicWindow {
34
fn hash<H: Hasher>(&self, state: &mut H) {
35
self.window_size.hash(state);
36
self.min_periods.hash(state);
37
self.closed_window.hash(state);
38
}
39
}
40
41