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/pow.rs
7889 views
1
use std::fmt;
2
3
use super::IRFunctionExpr;
4
use crate::prelude::FunctionOptions;
5
6
#[cfg_attr(feature = "ir_serde", derive(serde::Serialize, serde::Deserialize))]
7
#[derive(Clone, Copy, PartialEq, Debug, Eq, Hash)]
8
pub enum IRPowFunction {
9
Generic,
10
Sqrt,
11
Cbrt,
12
}
13
14
impl IRPowFunction {
15
pub fn function_options(&self) -> FunctionOptions {
16
use IRPowFunction as P;
17
match self {
18
P::Generic | P::Sqrt | P::Cbrt => FunctionOptions::elementwise(),
19
}
20
}
21
}
22
23
impl fmt::Display for IRPowFunction {
24
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> std::fmt::Result {
25
use self::*;
26
match self {
27
IRPowFunction::Generic => write!(f, "pow"),
28
IRPowFunction::Sqrt => write!(f, "sqrt"),
29
IRPowFunction::Cbrt => write!(f, "cbrt"),
30
}
31
}
32
}
33
34
impl From<IRPowFunction> for IRFunctionExpr {
35
fn from(value: IRPowFunction) -> Self {
36
Self::Pow(value)
37
}
38
}
39
40