Skip to content

Commit

Permalink
Merge pull request #40 from MarcoGorelli/fmt-allocator
Browse files Browse the repository at this point in the history
use allocator, run rustfmt
  • Loading branch information
MarcoGorelli authored Aug 15, 2024
2 parents e125fec + ea0ef89 commit 82121ee
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 43 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ jobs:
- name: Set up Rust
run: rustup show
- uses: mozilla-actions/[email protected]
- run: make .venv
- run: curl -LsSf https://astral.sh/uv/install.sh | sh
- run: uv venv --seed
- run: . .venv/bin/activate && uv pip install -r requirements.txt -r requirements-dev.txt
- run: make pre-commit
- run: make install
- run: make test
21 changes: 0 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,3 @@ reverse_geocoder = "4.1.1"
[patch.crates-io]
pyo3-polars = { git = 'https://github.com/MarcoGorelli/pyo3-polars.git', rev='a0327ec121986711aec32dc1e52234838bf3b25b' }

[target.'cfg(target_os = "linux")'.dependencies]
jemallocator = { version = "0.5", features = ["disable_initial_exec_tls"] }
15 changes: 5 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@

SHELL=/bin/bash

.venv: ## Set up virtual environment
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt
.venv/bin/pip install -r requirements-dev.txt

install: .venv
install:
unset CONDA_PREFIX && \
source .venv/bin/activate && maturin develop -m Cargo.toml

install-release: .venv
install-release:
unset CONDA_PREFIX && \
source .venv/bin/activate && maturin develop --release -m Cargo.toml

pre-commit: .venv
cargo fmt --all --manifest-path Cargo.toml && cargo clippy --all-features --manifest-path Cargo.toml
pre-commit:
cargo +nightly fmt --all --manifest-path Cargo.toml && cargo clippy --all-features --manifest-path Cargo.toml
.venv/bin/python -m ruff format minimal_plugin test_plugin.py
.venv/bin/python -m ruff check minimal_plugin test_plugin.py

Expand All @@ -25,5 +20,5 @@ run: install
run-release: install-release
source .venv/bin/activate && python run.py

test: .venv
test:
source .venv/bin/activate && pytest test_plugin.py
9 changes: 5 additions & 4 deletions src/expressions.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#![allow(clippy::unused_unit)]
use std::ops::{Add, Div, Mul, Sub};

use polars::export::num::{NumCast, Zero};
use polars::prelude::arity::{
binary_elementwise_into_string_amortized, broadcast_binary_elementwise,
Expand All @@ -12,7 +14,6 @@ use pyo3_polars::export::polars_core::export::num::Signed;
use pyo3_polars::export::polars_core::utils::arrow::array::PrimitiveArray;
use pyo3_polars::export::polars_core::utils::CustomIterTools;
use serde::Deserialize;
use std::ops::{Add, Div, Mul, Sub};

fn same_output_type(input_fields: &[Field]) -> PolarsResult<Field> {
let field = &input_fields[0];
Expand Down Expand Up @@ -54,7 +55,7 @@ fn abs_numeric(inputs: &[Series]) -> PolarsResult<Series> {
dtype => {
polars_bail!(InvalidOperation:format!("dtype {dtype} not \
supported for abs_numeric, expected Int32, Int64, Float32, Float64."))
}
},
}
}

Expand Down Expand Up @@ -84,7 +85,7 @@ fn cum_sum(inputs: &[Series]) -> PolarsResult<Series> {
Some(x) => {
*state += x;
Some(Some(*state))
}
},
None => Some(None),
})
.collect_trusted();
Expand Down Expand Up @@ -224,7 +225,7 @@ fn shifted_struct(input_fields: &[Field]) -> PolarsResult<Field> {
.collect::<Vec<_>>();
fields.push(field_0);
Ok(Field::new(&name, DataType::Struct(fields)))
}
},
_ => unreachable!(),
}
}
Expand Down
7 changes: 2 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
mod expressions;

#[cfg(target_os = "linux")]
use jemallocator::Jemalloc;
use pyo3_polars::PolarsAllocator;

#[global_allocator]
#[cfg(target_os = "linux")]
static ALLOC: Jemalloc = Jemalloc;
static ALLOC: PolarsAllocator = PolarsAllocator::new();

0 comments on commit 82121ee

Please sign in to comment.