-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests(rust): Add test for arithmetic & aggregate methods on sorted Ch…
…unkedArray (#5189) Co-authored-by: Danny van Kooten <dannyvankooten@users.noreply.github.com>
- Loading branch information
1 parent
2e6709c
commit c84611d
Showing
3 changed files
with
53 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use polars::prelude::*; | ||
use polars::series::*; | ||
|
||
#[test] | ||
fn test_series_arithmetic() { | ||
let a = &Series::new("a", &[1, 100, 6, 40]); | ||
let b = &Series::new("b", &[-1, 2, 3, 4]); | ||
assert_eq!(a + b, Series::new("a", &[0, 102, 9, 44])); | ||
assert_eq!(a - b, Series::new("a", &[2, 98, 3, 36])); | ||
assert_eq!(a * b, Series::new("a", &[-1, 200, 18, 160])); | ||
assert_eq!(a / b, Series::new("a", &[-1, 50, 2, 10])); | ||
} | ||
|
||
#[test] | ||
fn test_aggregates() { | ||
let a = &Series::new("a", &[9, 11, 10]); | ||
assert_eq!(a.max(), Some(11)); | ||
assert_eq!(a.min(), Some(9)); | ||
assert_eq!(a.sum(), Some(30)); | ||
assert_eq!(a.mean(), Some(10.0)); | ||
assert_eq!(a.median(), Some(10.0)); | ||
} | ||
|
||
#[test] | ||
fn test_min_max_sorted_asc() { | ||
let a = &mut Series::new("a", &[1, 2, 3, 4]); | ||
a.set_sorted(IsSorted::Ascending); | ||
assert_eq!(a.max(), Some(4)); | ||
assert_eq!(a.min(), Some(1)); | ||
} | ||
|
||
#[test] | ||
fn test_min_max_sorted_desc() { | ||
let mut a = &mut Series::new("a", &[4, 3, 2, 1]); | ||
a.set_sorted(IsSorted::Descending); | ||
assert_eq!(a.max(), Some(4)); | ||
assert_eq!(a.min(), Some(1)); | ||
} |