Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-plan/src/plans/aexpr/function_expr/cum.rs
7889 views
1
use super::*;
2
3
pub(super) mod dtypes {
4
use DataType::*;
5
use polars_core::utils::materialize_dyn_int;
6
7
use super::*;
8
9
pub fn cum_sum(dt: &DataType) -> DataType {
10
if dt.is_logical() {
11
dt.clone()
12
} else {
13
match dt {
14
Boolean => UInt32,
15
Int32 => Int32,
16
Int128 => Int128,
17
UInt32 => UInt32,
18
UInt64 => UInt64,
19
#[cfg(feature = "dtype-f16")]
20
Float16 => Float16,
21
Float32 => Float32,
22
Float64 => Float64,
23
Unknown(kind) => match kind {
24
UnknownKind::Int(v) => cum_sum(&materialize_dyn_int(*v).dtype()),
25
UnknownKind::Float => Float64,
26
_ => dt.clone(),
27
},
28
_ => Int64,
29
}
30
}
31
}
32
33
pub fn cum_prod(dt: &DataType) -> DataType {
34
match dt {
35
Boolean => Int64,
36
UInt64 => UInt64,
37
Int128 => Int128,
38
#[cfg(feature = "dtype-f16")]
39
Float16 => Float16,
40
Float32 => Float32,
41
Float64 => Float64,
42
_ => Int64,
43
}
44
}
45
}
46
47