Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
victoria de sainte agathe committed Nov 20, 2023
1 parent 52ce86f commit bcbd1d0
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/data_type/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1813,9 +1813,11 @@ pub fn floor() -> impl Function {
}

// Round function
// monotonic for the 1st variable but not for the second => Pointwise
pub fn round() -> impl Function {
PartitionnedMonotonic::bivariate(
Pointwise::bivariate(
(data_type::Float::default(), data_type::Integer::default()),
data_type::Float::default(),
|a, b| {
let multiplier = 10.0_f64.powi(b as i32);
(a * multiplier).round() / multiplier
Expand All @@ -1824,24 +1826,18 @@ pub fn round() -> impl Function {
}

// Trunc function
// monotonic for the 1st variable but not for the second (eg: when the 2nd arg is negative )=> Pointwise
pub fn trunc() -> impl Function {
PartitionnedMonotonic::bivariate(
Pointwise::bivariate(
(data_type::Float::default(), data_type::Integer::default()),
data_type::Float::default(),
|a, b| {
let multiplier = 10.0_f64.powi(b as i32);
(a * multiplier).trunc() / multiplier
}
)
}

// Sign function
pub fn sign() -> impl Function {
PartitionnedMonotonic::univariate(
data_type::Float::default(),
|a| a.signum()
)
}

/*
Aggregation functions
*/
Expand Down

0 comments on commit bcbd1d0

Please sign in to comment.