Skip to content

Commit

Permalink
chore: update rustc and clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Jan 2, 2022
1 parent ae69335 commit f64fdc0
Show file tree
Hide file tree
Showing 47 changed files with 217 additions and 174 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-12-02
rustup override set nightly-2022-01-01
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 @@ -12,7 +12,7 @@ jobs:
- name: Install latest Rust nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-12-02
toolchain: nightly-2022-01-01
override: true
components: rustfmt, clippy
- name: Set up Python
Expand All @@ -32,7 +32,7 @@ jobs:
source venv/bin/activate
pip install -r py-polars/build.requirements.txt
cd py-polars
rustup override set nightly-2021-12-02 && 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-2022-01-01 && 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
2 changes: 1 addition & 1 deletion .github/workflows/build-test.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-12-02
toolchain: nightly-2022-01-01
override: true
components: rustfmt, clippy, miri
- name: Cache Cargo
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/create-py-mac-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-12-02
toolchain: nightly-2022-01-01
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-12-02
rustup override set nightly-2022-01-01
- name: maturin publish
uses: messense/maturin-action@v1
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/create-py-release-windows-macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Install latest Rust nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-12-02
toolchain: nightly-2022-01-01
override: true
components: rustfmt, clippy
- name: Set up Python
Expand All @@ -37,7 +37,7 @@ jobs:
rm py-polars/README.md
cp README.md py-polars/README.md
cd py-polars
rustup override set nightly-2021-12-02
rustup override set nightly-2022-01-01
export RUSTFLAGS='-C target-feature=+fxsr,+sse,+sse2,+sse3'
maturin publish \
--no-sdist \
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-12-02
toolchain: nightly-2022-01-01
override: true
components: rustfmt, clippy
- name: Set up Node
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-js.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Install latest Rust nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-12-02
toolchain: nightly-2022-01-01
override: true
components: rustfmt, clippy
- run: yarn --version
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test-python.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-12-02
toolchain: nightly-2022-01-01
override: true
components: rustfmt, clippy
- name: Set up Python
Expand All @@ -30,7 +30,7 @@ jobs:
pip install -r py-polars/build.requirements.txt
- name: Run formatting checks
run: |
cd py-polars && black --check . && blackdoc --check . && isort --check . && rustup override set nightly-2021-12-02 && cargo fmt --all -- --check && cd ..
cd py-polars && black --check . && blackdoc --check . && isort --check . && rustup override set nightly-2022-01-01 && cargo fmt --all -- --check && cd ..
- name: Run linting
run: |
cd py-polars && flake8 && cd ..
Expand All @@ -40,7 +40,7 @@ jobs:
- name: Run tests
run: |
export RUSTFLAGS="-C debuginfo=0"
cd py-polars && rustup override set nightly-2021-12-02 && make venv && make test-with-cov
cd py-polars && rustup override set nightly-2022-01-01 && make venv && make test-with-cov
cargo clippy
- name: Check doc examples
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-windows-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Install latest Rust nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-12-02
toolchain: nightly-2022-01-01
override: true
components: rustfmt, clippy
- name: Set up Python
Expand All @@ -28,7 +28,7 @@ jobs:
shell: bash
run: |
export RUSTFLAGS="-C debuginfo=0"
cd py-polars && rustup override set nightly-2021-12-02 && make build-and-test-no-venv
cd py-polars && rustup override set nightly-2022-01-01 && make build-and-test-no-venv
cargo clippy
# test if we can import polars without any requirements
- name: Import polars
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-windows.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-12-02
toolchain: nightly-2022-01-01
override: true
- name: Run tests
run: |
Expand Down
2 changes: 1 addition & 1 deletion nodejs-polars/rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2021-12-02
nightly-2022-01-01
1 change: 1 addition & 0 deletions polars/polars-arrow/src/kernels/ewm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub use average::*;
pub use variance::*;

#[derive(Debug, Copy, Clone)]
#[must_use]
pub struct EWMOptions {
pub alpha: f64,
pub adjust: bool,
Expand Down
15 changes: 5 additions & 10 deletions polars/polars-core/src/chunked_array/iterator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ impl BooleanChunked {
// we know that we only iterate over length == self.len()
unsafe {
self.downcast_iter()
.map(BoolIterNoNull::new)
.flatten()
.flat_map(BoolIterNoNull::new)
.trust_my_length(self.len())
}
}
Expand Down Expand Up @@ -216,8 +215,7 @@ impl Utf8Chunked {
// we know that we only iterate over length == self.len()
unsafe {
self.downcast_iter()
.map(Utf8IterNoNull::new)
.flatten()
.flat_map(Utf8IterNoNull::new)
.trust_my_length(self.len())
}
}
Expand All @@ -233,8 +231,7 @@ impl<'a> IntoIterator for &'a ListChunked {
unsafe {
Box::new(
self.downcast_iter()
.map(|arr| arr.iter())
.flatten()
.flat_map(|arr| arr.iter())
.trust_my_length(self.len())
.map(move |arr| {
arr.map(|arr| {
Expand Down Expand Up @@ -314,8 +311,7 @@ impl ListChunked {
// we know that we only iterate over length == self.len()
unsafe {
self.downcast_iter()
.map(ListIterNoNull::new)
.flatten()
.flat_map(ListIterNoNull::new)
.trust_my_length(self.len())
}
}
Expand Down Expand Up @@ -344,8 +340,7 @@ impl<T: PolarsObject> ObjectChunked<T> {
// we know that we only iterate over length == self.len()
unsafe {
self.downcast_iter()
.map(|arr| arr.values().iter())
.flatten()
.flat_map(|arr| arr.values().iter())
.trust_my_length(self.len())
}
}
Expand Down
3 changes: 2 additions & 1 deletion polars/polars-core/src/chunked_array/list/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,13 @@ impl ListChunked {
series_container,
inner: NonNull::new(ptr).unwrap(),
lifetime: PhantomData,
iter: self.downcast_iter().map(|arr| arr.iter()).flatten(),
iter: self.downcast_iter().flat_map(|arr| arr.iter()),
}
}

/// Apply a closure `F` elementwise.
#[cfg(feature = "private")]
#[must_use]
pub fn apply_amortized<'a, F>(&'a self, mut f: F) -> Self
where
F: FnMut(UnstableSeries<'a>) -> Series,
Expand Down
4 changes: 3 additions & 1 deletion polars/polars-core/src/chunked_array/list/namespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ impl ListChunked {

pub fn lst_mean(&self) -> Float64Chunked {
self.amortized_iter()
.map(|s| s.map(|s| s.as_ref().mean()).flatten())
.map(|s| s.and_then(|s| s.as_ref().mean()))
.collect()
}

#[must_use]
pub fn lst_sort(&self, reverse: bool) -> ListChunked {
self.apply_amortized(|s| s.as_ref().sort(reverse))
}

#[must_use]
pub fn lst_reverse(&self) -> ListChunked {
self.apply_amortized(|s| s.as_ref().reverse())
}
Expand Down
1 change: 1 addition & 0 deletions polars/polars-core/src/chunked_array/ops/abs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ where
T::Native: Signed,
{
/// Convert all values to their absolute/positive value.
#[must_use]
pub fn abs(&self) -> Self {
self.apply(|v| v.abs())
}
Expand Down
11 changes: 5 additions & 6 deletions polars/polars-core/src/chunked_array/ops/chunkops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ fn slice(
remaining_offset -= chunk_len;
continue;
}
let take_len;
if remaining_length + remaining_offset > chunk_len {
take_len = chunk_len - remaining_offset;
let take_len = if remaining_length + remaining_offset > chunk_len {
chunk_len - remaining_offset
} else {
take_len = remaining_length;
}
remaining_length
};

new_chunks.push(chunk.slice(remaining_offset, take_len).into());
remaining_length -= take_len;
Expand Down Expand Up @@ -216,7 +215,7 @@ mod test {
let mut a = s.cast(&DataType::Categorical).unwrap();

a.append(&a.slice(0, 2)).unwrap();
a.rechunk();
let a = a.rechunk();
assert!(a.categorical().unwrap().categorical_map.is_some());
}
}
12 changes: 12 additions & 0 deletions polars/polars-core/src/chunked_array/ops/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub trait ToList<T: PolarsDataType> {

#[cfg(feature = "interpolate")]
pub trait Interpolate {
#[must_use]
fn interpolate(&self) -> Self;
}

Expand Down Expand Up @@ -199,6 +200,7 @@ pub trait ChunkTake {
/// # Safety
///
/// Doesn't do any bound checking.
#[must_use]
unsafe fn take_unchecked<I, INulls>(&self, indices: TakeIdx<I, INulls>) -> Self
where
Self: std::marker::Sized,
Expand Down Expand Up @@ -324,6 +326,7 @@ pub trait ChunkApply<'a, A, B> {
/// ca.apply(|v| v * 2)
/// }
/// ```
#[must_use]
fn apply<F>(&'a self, f: F) -> Self
where
F: Fn(A) -> B + Copy;
Expand All @@ -334,16 +337,19 @@ pub trait ChunkApply<'a, A, B> {
Self: Sized;

/// Apply a closure elementwise including null values.
#[must_use]
fn apply_on_opt<F>(&'a self, f: F) -> Self
where
F: Fn(Option<A>) -> Option<B> + Copy;

/// Apply a closure elementwise. The closure gets the index of the element as first argument.
#[must_use]
fn apply_with_idx<F>(&'a self, f: F) -> Self
where
F: Fn((usize, A)) -> B + Copy;

/// Apply a closure elementwise. The closure gets the index of the element as first argument.
#[must_use]
fn apply_with_idx_on_opt<F>(&'a self, f: F) -> Self
where
F: Fn((usize, Option<A>)) -> Option<B> + Copy;
Expand Down Expand Up @@ -689,6 +695,7 @@ pub trait ChunkZip<T> {
/// Apply kernels on the arrow array chunks in a ChunkedArray.
pub trait ChunkApplyKernel<A: Array> {
/// Apply kernel and return result as a new ChunkedArray.
#[must_use]
fn apply_kernel<F>(&self, f: F) -> Self
where
F: Fn(&A) -> ArrayRef;
Expand Down Expand Up @@ -790,6 +797,7 @@ pub trait ChunkLen {

pub trait ChunkOps: ChunkLen {
/// Aggregate to contiguous memory.
#[must_use]
fn rechunk(&self) -> Self
where
Self: std::marker::Sized;
Expand All @@ -799,11 +807,13 @@ pub trait ChunkOps: ChunkLen {
/// When offset is negative it will be counted from the end of the array.
/// This method will never error,
/// and will slice the best match when offset, or length is out of bounds
#[must_use]
fn slice(&self, offset: i64, length: usize) -> Self
where
Self: std::marker::Sized;

/// Take a view of top n elements
#[must_use]
fn limit(&self, num_elements: usize) -> Self
where
Self: Sized,
Expand All @@ -812,6 +822,7 @@ pub trait ChunkOps: ChunkLen {
}

/// Get the head of the ChunkedArray
#[must_use]
fn head(&self, length: Option<usize>) -> Self
where
Self: Sized,
Expand All @@ -823,6 +834,7 @@ pub trait ChunkOps: ChunkLen {
}

/// Get the tail of the ChunkedArray
#[must_use]
fn tail(&self, length: Option<usize>) -> Self
where
Self: Sized,
Expand Down
2 changes: 2 additions & 0 deletions polars/polars-core/src/chunked_array/strings/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ impl Utf8Chunked {
}
}
#[cfg(feature = "string_encoding")]
#[must_use]
pub fn hex_encode(&self) -> Utf8Chunked {
self.apply(|s| hex::encode(s).into())
}
Expand All @@ -47,6 +48,7 @@ impl Utf8Chunked {
}

#[cfg(feature = "string_encoding")]
#[must_use]
pub fn base64_encode(&self) -> Utf8Chunked {
self.apply(|s| base64::encode(s).into())
}
Expand Down
3 changes: 3 additions & 0 deletions polars/polars-core/src/chunked_array/strings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,19 @@ impl Utf8Chunked {
}

/// Modify the strings to their lowercase equivalent
#[must_use]
pub fn to_lowercase(&self) -> Utf8Chunked {
self.apply(|s| str::to_lowercase(s).into())
}

/// Modify the strings to their uppercase equivalent
#[must_use]
pub fn to_uppercase(&self) -> Utf8Chunked {
self.apply(|s| str::to_uppercase(s).into())
}

/// Concat with the values from a second Utf8Chunked
#[must_use]
pub fn concat(&self, other: &Utf8Chunked) -> Self {
self + other
}
Expand Down

0 comments on commit f64fdc0

Please sign in to comment.