Skip to content

Commit

Permalink
CI: update rustc and fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Oct 3, 2021
1 parent a4464e9 commit 43fa784
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .github/deploy_manylinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ls -la
rm py-polars/README.md
cp README.md py-polars/README.md
cd py-polars
rustup override set nightly-2021-09-14
rustup override set nightly-2021-10-03
export RUSTFLAGS='-C target-feature=+fxsr,+sse,+sse2,+sse3,+ssse3,+sse4.1,+popcnt'
maturin publish \
--skip-existing \
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/benchmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- name: Install latest Rust nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-09-14
toolchain: nightly-2021-10-03
override: true
components: rustfmt, clippy
- name: Set up Python
Expand All @@ -31,7 +31,7 @@ jobs:
pip install -r py-polars/build.requirements.txt
pip install --only-binary all pyarrow
cd py-polars
rustup override set nightly-2021-09-14 && RUSTFLAGS="-C embed-bitcode" maturin develop --rustc-extra-args="-C codegen-units=8 -C lto=thin -C target-cpu=native" --release
rustup override set nightly-2021-10-03 && RUSTFLAGS="-C embed-bitcode" maturin develop --rustc-extra-args="-C codegen-units=8 -C lto=thin -C target-cpu=native" --release
cd tests/db-benchmark
Rscript -e 'install.packages("data.table", repos="https://Rdatatable.github.io/data.table")'
Rscript groupby-datagen.R 1e7 1e2 5 0
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Install latest Rust nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-09-14
toolchain: nightly-2021-10-03
override: true
components: rustfmt, clippy, miri
- name: Cache Cargo
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
- name: Install latest Rust nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-09-14
toolchain: nightly-2021-10-03
override: true
components: rustfmt, clippy
- name: Set up Python
Expand All @@ -93,7 +93,7 @@ jobs:
- name: Run tests
run: |
export RUSTFLAGS="-C debuginfo=0"
cd py-polars && rustup override set nightly-2021-09-14 && make build-and-test
cd py-polars && rustup override set nightly-2021-10-03 && make build-and-test
cargo clippy
# test if we can import polars without any requirements
- name: Import polars
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/create-py-release-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Install latest Rust nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-09-14
toolchain: nightly-2021-10-03
override: true
components: rustfmt, clippy
- name: Set up Python
Expand All @@ -31,7 +31,7 @@ jobs:
- name: Run tests
run: |
cd py-polars
rustup override set nightly-2021-09-14
rustup override set nightly-2021-10-03
make build-and-test
rm wheels/*
Expand All @@ -48,7 +48,7 @@ jobs:
- name: Install latest Rust nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-09-14
toolchain: nightly-2021-10-03
override: true
components: rustfmt, clippy
- name: Set up Python
Expand All @@ -67,7 +67,7 @@ jobs:
rm py-polars/README.md
cp README.md py-polars/README.md
cd py-polars
rustup override set nightly-2021-09-14
rustup override set nightly-2021-10-03
export RUSTFLAGS='-C target-feature=+fxsr,+sse,+sse2,+sse3'
maturin publish \
--skip-existing \
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/create-py-universal2-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install latest Rust nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-09-14
toolchain: nightly-2021-10-03
override: true
components: rustfmt, clippy
- name: Setup universal2 targets for Rust
Expand All @@ -35,7 +35,7 @@ jobs:
rm py-polars/README.md
cp README.md py-polars/README.md
cd py-polars
rustup override set nightly-2021-09-14
rustup override set nightly-2021-10-03
- name: maturin publish
uses: messense/maturin-action@v1
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Install latest Rust nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-09-14
toolchain: nightly-2021-10-03
override: true
components: rustfmt, clippy
- name: Set up Python
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- name: Install latest Rust nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-09-14
toolchain: nightly-2021-10-03
override: true
- name: Run tests
run: |
Expand All @@ -24,7 +24,7 @@ jobs:
- name: Install latest Rust nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-09-14
toolchain: nightly-2021-10-03
override: true
components: rustfmt, clippy
- name: Set up Python
Expand All @@ -39,7 +39,7 @@ jobs:
shell: bash
run: |
export RUSTFLAGS="-C debuginfo=0"
cd py-polars && rustup override set nightly-2021-09-14 && make build-and-test
cd py-polars && rustup override set nightly-2021-10-03 && make build-and-test
cargo clippy
# test if we can import polars without any requirements
- name: Import polars
Expand Down
6 changes: 3 additions & 3 deletions polars/polars-core/src/chunked_array/iterator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl BooleanChunked {
+ DoubleEndedIterator
+ TrustedLen {
self.downcast_iter()
.map(|bool_arr| BoolIterNoNull::new(bool_arr))
.map(BoolIterNoNull::new)
.flatten()
.trust_my_length(self.len())
}
Expand Down Expand Up @@ -206,7 +206,7 @@ impl Utf8Chunked {
+ DoubleEndedIterator
+ TrustedLen {
self.downcast_iter()
.map(|arr| Utf8IterNoNull::new(arr))
.map(Utf8IterNoNull::new)
.flatten()
.trust_my_length(self.len())
}
Expand Down Expand Up @@ -292,7 +292,7 @@ impl ListChunked {
+ DoubleEndedIterator
+ TrustedLen {
self.downcast_iter()
.map(|arr| ListIterNoNull::new(arr))
.map(ListIterNoNull::new)
.flatten()
.trust_my_length(self.len())
}
Expand Down
6 changes: 3 additions & 3 deletions polars/polars-core/src/chunked_array/ops/aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ where
{
fn sum(&self) -> Option<T::Native> {
self.downcast_iter()
.map(|a| compute::aggregate::sum_primitive(a))
.map(compute::aggregate::sum_primitive)
.fold(None, |acc, v| match v {
Some(v) => match acc {
None => Some(v),
Expand All @@ -79,13 +79,13 @@ where

fn min(&self) -> Option<T::Native> {
self.downcast_iter()
.filter_map(|a| compute::aggregate::min_primitive(a))
.filter_map(compute::aggregate::min_primitive)
.fold_first_(|acc, v| if acc < v { acc } else { v })
}

fn max(&self) -> Option<T::Native> {
self.downcast_iter()
.filter_map(|a| compute::aggregate::max_primitive(a))
.filter_map(compute::aggregate::max_primitive)
.fold_first_(|acc, v| if acc > v { acc } else { v })
}

Expand Down
16 changes: 4 additions & 12 deletions polars/polars-core/src/chunked_array/ops/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ impl<'a> ChunkApply<'a, &'a str, Cow<'a, str>> for Utf8Chunked {
.downcast_iter()
.into_iter()
.map(|array| {
let values = array.values_iter().map(|x| f(x));
let values = array.values_iter().map(f);
let values = AlignedVec::<_>::from_trusted_len_iter(values);
to_array::<S>(values, array.validity().cloned())
})
Expand All @@ -297,7 +297,7 @@ impl<'a> ChunkApply<'a, &'a str, Cow<'a, str>> for Utf8Chunked {
.downcast_iter()
.into_iter()
.map(|array| {
let values = array.into_iter().map(|x| f(x));
let values = array.into_iter().map(f);
let values = AlignedVec::<_>::from_trusted_len_iter(values);
to_array::<S>(values, array.validity().cloned())
})
Expand Down Expand Up @@ -368,11 +368,7 @@ impl ChunkApplyKernel<BooleanArray> for BooleanChunked {
where
F: Fn(&BooleanArray) -> ArrayRef,
{
let chunks = self
.downcast_iter()
.into_iter()
.map(|array| f(array))
.collect();
let chunks = self.downcast_iter().into_iter().map(f).collect();
Self::new_from_chunks(self.name(), chunks)
}

Expand All @@ -381,11 +377,7 @@ impl ChunkApplyKernel<BooleanArray> for BooleanChunked {
F: Fn(&BooleanArray) -> ArrayRef,
S: PolarsDataType,
{
let chunks = self
.downcast_iter()
.into_iter()
.map(|array| f(array))
.collect();
let chunks = self.downcast_iter().into_iter().map(f).collect();
ChunkedArray::<S>::new_from_chunks(self.name(), chunks)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ impl Date64Chunked {
NaiveDateTime::parse_from_str(s, fmt)
.ok()
.as_ref()
.map(|v| naive_datetime_to_date64(v))
.map(naive_datetime_to_date64)
}),
)
}
Expand Down
7 changes: 4 additions & 3 deletions polars/polars-core/src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,10 @@ fn prepare_row(row: Vec<Cow<'_, str>>, n_first: usize, n_last: usize) -> Vec<Str
impl Display for DataFrame {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
let height = self.height();
if !self.columns.iter().all(|s| s.len() == height) {
panic!("The columns lengths in the DataFrame are not equal.");
}
assert!(
self.columns.iter().all(|s| s.len() == height),
"The columns lengths in the DataFrame are not equal."
);

let max_n_cols = std::env::var("POLARS_FMT_MAX_COLS")
.unwrap_or_else(|_| "8".to_string())
Expand Down
21 changes: 12 additions & 9 deletions polars/polars-lazy/src/dsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -772,17 +772,19 @@ impl Expr {

/// Get unique values of this expression.
pub fn unique(self) -> Self {
if has_expr(&self, |e| matches!(e, Expr::Wildcard)) {
panic!("wildcard not supperted in unique expr");
}
assert!(
!has_expr(&self, |e| matches!(e, Expr::Wildcard)),
"wildcard not supperted in unique expr"
);
self.apply(|s: Series| s.unique(), GetOutput::same_type())
}

/// Get the first index of unique values of this expression.
pub fn arg_unique(self) -> Self {
if has_expr(&self, |e| matches!(e, Expr::Wildcard)) {
panic!("wildcard not supported in unique expr");
}
assert!(
!has_expr(&self, |e| matches!(e, Expr::Wildcard)),
"wildcard not supported in unique expr"
);
self.apply(
|s: Series| s.arg_unique().map(|ca| ca.into_series()),
GetOutput::from_type(DataType::UInt32),
Expand All @@ -791,9 +793,10 @@ impl Expr {

/// Get the index values that would sort this expression.
pub fn arg_sort(self, reverse: bool) -> Self {
if has_expr(&self, |e| matches!(e, Expr::Wildcard)) {
panic!("wildcard not supported in unique expr");
}
assert!(
!has_expr(&self, |e| matches!(e, Expr::Wildcard)),
"wildcard not supported in unique expr"
);
self.apply(
move |s: Series| Ok(s.argsort(reverse).into_series()),
GetOutput::from_type(DataType::UInt32),
Expand Down
2 changes: 1 addition & 1 deletion polars/polars-lazy/src/logical_plan/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl AExpr {
push(falsy);
push(predicate)
}
Function { input, .. } => input.iter().for_each(|e| push(e)),
Function { input, .. } => input.iter().for_each(push),
Shift { input, .. } => push(input),
Reverse(e) => push(e),
Duplicated(e) => push(e),
Expand Down
2 changes: 1 addition & 1 deletion polars/polars-lazy/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub(crate) fn has_expr<F>(current_expr: &Expr, matches: F) -> bool
where
F: Fn(&Expr) -> bool,
{
current_expr.into_iter().any(|e| matches(e))
current_expr.into_iter().any(matches)
}

// this one is used so much that it has its own function, to reduce inlining
Expand Down

0 comments on commit 43fa784

Please sign in to comment.