Skip to content

Commit

Permalink
refactor: add missing polars-ops tests to CI (pola-rs#11859)
Browse files Browse the repository at this point in the history
  • Loading branch information
orlp authored Oct 19, 2023
1 parent f41e8f4 commit dfbc5f4
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 44 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/test-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,29 @@ jobs:
- name: Compile tests
run: >
cargo test --all-features --no-run
-p polars-core
-p polars-io
-p polars-lazy
-p polars-ops
-p polars-plan
-p polars-io
-p polars-core
-p polars-time
-p polars-utils
-p polars-row
-p polars-sql
-p polars-time
-p polars-utils
- name: Run tests
if: github.ref_name != 'main'
run: >
cargo test --all-features
-p polars-core
-p polars-io
-p polars-lazy
-p polars-ops
-p polars-plan
-p polars-io
-p polars-core
-p polars-time
-p polars-utils
-p polars-row
-p polars-sql
-p polars-time
-p polars-utils
integration-test:
runs-on: ${{ matrix.os }}
Expand Down
24 changes: 12 additions & 12 deletions crates/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,30 @@ miri: ## Run miri
.PHONY: test
test: ## Run tests
cargo test --all-features \
-p polars-lazy \
-p polars-io \
-p polars-core \
-p polars-time \
-p polars-utils \
-p polars-row \
-p polars-sql \
-p polars-io \
-p polars-lazy \
-p polars-ops \
-p polars-plan \
-p polars-row \
-p polars-sql \
-p polars-time \
-p polars-utils \
-- \
--test-threads=2

.PHONY: nextest
nextest: ## Run tests with nextest
cargo nextest run --all-features \
-p polars-lazy \
-p polars-io \
-p polars-core \
-p polars-time \
-p polars-utils \
-p polars-row \
-p polars-sql \
-p polars-io \
-p polars-lazy \
-p polars-ops \
-p polars-plan \
-p polars-row \
-p polars-sql \
-p polars-time \
-p polars-utils \

.PHONY: integration-tests
integration-tests: ## Run integration tests
Expand Down
27 changes: 19 additions & 8 deletions crates/polars-ops/src/chunked_array/interpolate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,26 +242,34 @@ mod test {
fn test_interpolate() {
let ca = UInt32Chunked::new("", &[Some(1), None, None, Some(4), Some(5)]);
let out = interpolate(&ca.into_series(), InterpolationMethod::Linear);
let out = out.u32().unwrap();
let out = out.f64().unwrap();
assert_eq!(
Vec::from(out),
&[Some(1), Some(2), Some(3), Some(4), Some(5)]
&[Some(1.0), Some(2.0), Some(3.0), Some(4.0), Some(5.0)]
);

let ca = UInt32Chunked::new("", &[None, Some(1), None, None, Some(4), Some(5)]);
let out = interpolate(&ca.into_series(), InterpolationMethod::Linear);
let out = out.u32().unwrap();
let out = out.f64().unwrap();
assert_eq!(
Vec::from(out),
&[None, Some(1), Some(2), Some(3), Some(4), Some(5)]
&[None, Some(1.0), Some(2.0), Some(3.0), Some(4.0), Some(5.0)]
);

let ca = UInt32Chunked::new("", &[None, Some(1), None, None, Some(4), Some(5), None]);
let out = interpolate(&ca.into_series(), InterpolationMethod::Linear);
let out = out.u32().unwrap();
let out = out.f64().unwrap();
assert_eq!(
Vec::from(out),
&[None, Some(1), Some(2), Some(3), Some(4), Some(5), None]
&[
None,
Some(1.0),
Some(2.0),
Some(3.0),
Some(4.0),
Some(5.0),
None
]
);
let ca = UInt32Chunked::new("", &[None, Some(1), None, None, Some(4), Some(5), None]);
let out = interpolate(&ca.into_series(), InterpolationMethod::Nearest);
Expand All @@ -276,8 +284,11 @@ mod test {
fn test_interpolate_decreasing_unsigned() {
let ca = UInt32Chunked::new("", &[Some(4), None, None, Some(1)]);
let out = interpolate(&ca.into_series(), InterpolationMethod::Linear);
let out = out.u32().unwrap();
assert_eq!(Vec::from(out), &[Some(4), Some(3), Some(2), Some(1)])
let out = out.f64().unwrap();
assert_eq!(
Vec::from(out),
&[Some(4.0), Some(3.0), Some(2.0), Some(1.0)]
)
}

#[test]
Expand Down
6 changes: 5 additions & 1 deletion crates/polars-ops/src/frame/join/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,13 @@ pub trait DataFrameJoinOps: IntoDf {
///
/// ```no_run
/// # use polars_core::prelude::*;
/// # use polars_ops::prelude::*;
/// let df1: DataFrame = df!("Fruit" => &["Apple", "Banana", "Pear"],
/// "Phosphorus (mg/100g)" => &[11, 22, 12])?;
/// let df2: DataFrame = df!("Name" => &["Apple", "Banana", "Pear"],
/// "Potassium (mg/100g)" => &[107, 358, 115])?;
///
/// let df3: DataFrame = df1.join(&df2, ["Fruit"], ["Name"], JoinType::Inner, None)?;
/// let df3: DataFrame = df1.join(&df2, ["Fruit"], ["Name"], JoinArgs::new(JoinType::Inner))?;
/// assert_eq!(df3.shape(), (3, 3));
/// println!("{}", df3);
/// # Ok::<(), PolarsError>(())
Expand Down Expand Up @@ -373,6 +374,7 @@ pub trait DataFrameJoinOps: IntoDf {
///
/// ```
/// # use polars_core::prelude::*;
/// # use polars_ops::prelude::*;
/// fn join_dfs(left: &DataFrame, right: &DataFrame) -> PolarsResult<DataFrame> {
/// left.inner_join(right, ["join_column_left"], ["join_column_right"])
/// }
Expand All @@ -395,6 +397,7 @@ pub trait DataFrameJoinOps: IntoDf {
///
/// ```no_run
/// # use polars_core::prelude::*;
/// # use polars_ops::prelude::*;
/// let df1: DataFrame = df!("Wavelength (nm)" => &[480.0, 650.0, 577.0, 1201.0, 100.0])?;
/// let df2: DataFrame = df!("Color" => &["Blue", "Yellow", "Red"],
/// "Wavelength nm" => &[480.0, 577.0, 650.0])?;
Expand Down Expand Up @@ -437,6 +440,7 @@ pub trait DataFrameJoinOps: IntoDf {
///
/// ```
/// # use polars_core::prelude::*;
/// # use polars_ops::prelude::*;
/// fn join_dfs(left: &DataFrame, right: &DataFrame) -> PolarsResult<DataFrame> {
/// left.outer_join(right, ["join_column_left"], ["join_column_right"])
/// }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//! # Examples
//!
//! ```
//! # use polars_ops::prelude::*;
//! let mut hllp = HyperLogLog::new();
//! hllp.add(&12345);
//! hllp.add(&23456);
Expand Down
2 changes: 2 additions & 0 deletions crates/polars-plan/src/dsl/functions/temporal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ pub fn datetime(args: DatetimeArgs) -> Expr {
/// their default value of `lit(0)`, as demonstrated below.
///
/// ```
/// # use polars_plan::prelude::*;
/// let args = DurationArgs {
/// days: lit(5),
/// hours: col("num_hours"),
Expand All @@ -165,6 +166,7 @@ pub fn datetime(args: DatetimeArgs) -> Expr {
/// ```
/// If you prefer builder syntax, `with_*` methods are also available.
/// ```
/// # use polars_plan::prelude::*;
/// let args = DurationArgs::new().with_weeks(lit(42)).with_hours(lit(84));
/// ```
#[derive(Debug, Clone)]
Expand Down
16 changes: 1 addition & 15 deletions crates/polars-plan/src/dsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,7 @@ impl Expr {
/// Keep the original root name
///
/// ```rust,no_run
/// # use polars_core::prelude::*;
/// # use polars_plan::prelude::*;
/// fn example(df: LazyFrame) -> LazyFrame {
/// df.select([
Expand Down Expand Up @@ -1181,21 +1182,6 @@ impl Expr {
/// Exclude a column from a wildcard/regex selection.
///
/// You may also use regexes in the exclude as long as they start with `^` and end with `$`/
///
/// # Example
///
/// ```rust
/// use polars_core::prelude::*;
/// use polars_lazy::prelude::*;
///
/// // Select all columns except foo.
/// fn example(df: DataFrame) -> LazyFrame {
/// df.lazy()
/// .select(&[
/// col("*").exclude(&["foo"])
/// ])
/// }
/// ```
pub fn exclude(self, columns: impl IntoVec<String>) -> Expr {
let v = columns
.into_vec()
Expand Down

0 comments on commit dfbc5f4

Please sign in to comment.