Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
Removed one nest.
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecarleitao committed Sep 29, 2021
1 parent fedb19f commit 43a17c5
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 24 deletions.
26 changes: 19 additions & 7 deletions src/compute/arithmetics/basic/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
//! Defines the arithmetic kernels for `PrimitiveArrays`.
pub mod add;
pub mod div;
pub mod mul;
pub mod pow;
pub mod rem;
pub mod sub;
//! Contains arithemtic functions for [`PrimitiveArray`](crate::array::PrimitiveArray)s.
//!
//! Each operation has four variants, like the rest of Rust's ecosystem:
//! * usual, that [`panic!`]s on overflow
//! * `checked_*` that turns overflowings to `None`
//! * `overflowing_*` returning a [`Bitmap`](crate::bitmap::Bitmap) with items that overflow.
//! * `saturating_*` that saturates the result.
mod add;
pub use add::*;
mod div;
pub use div::*;
mod mul;
pub use mul::*;
mod pow;
pub use pow::*;
mod rem;
pub use rem::*;
mod sub;
pub use sub::*;
20 changes: 10 additions & 10 deletions src/compute/arithmetics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,11 @@ where
+ Rem<Output = T>,
{
match op {
Operator::Add => basic::add::add(lhs, rhs),
Operator::Subtract => basic::sub::sub(lhs, rhs),
Operator::Multiply => basic::mul::mul(lhs, rhs),
Operator::Divide => basic::div::div(lhs, rhs),
Operator::Remainder => basic::rem::rem(lhs, rhs),
Operator::Add => basic::add(lhs, rhs),
Operator::Subtract => basic::sub(lhs, rhs),
Operator::Multiply => basic::mul(lhs, rhs),
Operator::Divide => basic::div(lhs, rhs),
Operator::Remainder => basic::rem(lhs, rhs),
}
}

Expand All @@ -275,11 +275,11 @@ where
+ NumCast,
{
match op {
Operator::Add => Ok(basic::add::add_scalar(lhs, rhs)),
Operator::Subtract => Ok(basic::sub::sub_scalar(lhs, rhs)),
Operator::Multiply => Ok(basic::mul::mul_scalar(lhs, rhs)),
Operator::Divide => Ok(basic::div::div_scalar(lhs, rhs)),
Operator::Remainder => Ok(basic::rem::rem_scalar(lhs, rhs)),
Operator::Add => Ok(basic::add_scalar(lhs, rhs)),
Operator::Subtract => Ok(basic::sub_scalar(lhs, rhs)),
Operator::Multiply => Ok(basic::mul_scalar(lhs, rhs)),
Operator::Divide => Ok(basic::div_scalar(lhs, rhs)),
Operator::Remainder => Ok(basic::rem_scalar(lhs, rhs)),
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/it/compute/aggregate/sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn test_primitive_array_sum_large_64() {
.map(|i| if i % 3 == 0 { Some(0) } else { Some(i) })
.collect();
// create an array that actually has non-zero values at the invalid indices
let c = arithmetics::basic::add::add(&a, &b).unwrap();
let c = arithmetics::add::add(&a, &b).unwrap();
assert_eq!(
Some((1..=100).filter(|i| i % 3 == 0).sum()),
sum_primitive(&c)
Expand Down
2 changes: 1 addition & 1 deletion tests/it/compute/arithmetics/basic/add.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use arrow2::array::*;
use arrow2::bitmap::Bitmap;
use arrow2::compute::arithmetics::basic::add::*;
use arrow2::compute::arithmetics::basic::*;
use arrow2::compute::arithmetics::{
ArrayAdd, ArrayCheckedAdd, ArrayOverflowingAdd, ArraySaturatingAdd,
};
Expand Down
2 changes: 1 addition & 1 deletion tests/it/compute/arithmetics/basic/div.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use arrow2::array::*;
use arrow2::compute::arithmetics::basic::div::*;
use arrow2::compute::arithmetics::basic::*;
use arrow2::compute::arithmetics::{ArrayCheckedDiv, ArrayDiv};

#[test]
Expand Down
2 changes: 1 addition & 1 deletion tests/it/compute/arithmetics/basic/mul.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use arrow2::array::*;
use arrow2::bitmap::Bitmap;
use arrow2::compute::arithmetics::basic::mul::*;
use arrow2::compute::arithmetics::basic::*;
use arrow2::compute::arithmetics::{
ArrayCheckedMul, ArrayMul, ArrayOverflowingMul, ArraySaturatingMul,
};
Expand Down
2 changes: 1 addition & 1 deletion tests/it/compute/arithmetics/basic/pow.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use arrow2::array::*;
use arrow2::compute::arithmetics::basic::pow::*;
use arrow2::compute::arithmetics::basic::*;

#[test]
fn test_raise_power_scalar() {
Expand Down
2 changes: 1 addition & 1 deletion tests/it/compute/arithmetics/basic/rem.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use arrow2::array::*;
use arrow2::compute::arithmetics::basic::rem::*;
use arrow2::compute::arithmetics::basic::*;
use arrow2::compute::arithmetics::{ArrayCheckedRem, ArrayRem};

#[test]
Expand Down
2 changes: 1 addition & 1 deletion tests/it/compute/arithmetics/basic/sub.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use arrow2::array::*;
use arrow2::bitmap::Bitmap;
use arrow2::compute::arithmetics::basic::sub::*;
use arrow2::compute::arithmetics::basic::*;
use arrow2::compute::arithmetics::{
ArrayCheckedSub, ArrayOverflowingSub, ArraySaturatingSub, ArraySub,
};
Expand Down

0 comments on commit 43a17c5

Please sign in to comment.