Skip to content

Commit

Permalink
pyo3-polars 0.10.0 (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 authored Jan 2, 2024
1 parent d28aae0 commit e39357c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ members = [
]

[workspace.dependencies]
polars = { version = "0.35", default-features = false }
polars-core = { version = "0.35", default-features = false }
polars-ffi = { version = "0.35", default-features = false }
polars-plan = { version = "0.35", default-feautres = false }
polars-lazy = { version = "0.35", default-features = false }
polars = { version = "0.36.2", default-features = false }
polars-core = { version = "0.36.2", default-features = false }
polars-ffi = { version = "0.36.2", default-features = false }
polars-plan = { version = "0.36.2", default-feautres = false }
polars-lazy = { version = "0.36.2", default-features = false }
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ struct PigLatinKwargs {
capitalize: bool,
}

#[polars_expr(output_type=Utf8)]
#[polars_expr(output_type=String)]
fn pig_latinnify(inputs: &[Series], kwargs: PigLatinKwargs) -> PolarsResult<Series> {
let ca = inputs[0].utf8()?;
let out: Utf8Chunked =
let ca = inputs[0].str()?;
let out: StringChunked =
ca.apply_to_buffer(|value, output| pig_latin_str(value, kwargs.capitalize, output));
Ok(out.into_series())
}
Expand Down
24 changes: 12 additions & 12 deletions example/derive_expression/expression_lib/src/expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ fn pig_latin_str(value: &str, capitalize: bool, output: &mut String) {
}
}

#[polars_expr(output_type=Utf8)]
#[polars_expr(output_type=String)]
fn pig_latinnify(inputs: &[Series], kwargs: PigLatinKwargs) -> PolarsResult<Series> {
let ca = inputs[0].utf8()?;
let out: Utf8Chunked =
let ca = inputs[0].str()?;
let out: StringChunked =
ca.apply_to_buffer(|value, output| pig_latin_str(value, kwargs.capitalize, output));
Ok(out.into_series())
}
Expand All @@ -53,17 +53,17 @@ fn split_offsets(len: usize, n: usize) -> Vec<(usize, usize)> {
}

/// This expression will run in parallel if the `context` allows it.
#[polars_expr(output_type=Utf8)]
#[polars_expr(output_type=String)]
fn pig_latinnify_with_paralellism(
inputs: &[Series],
context: CallerContext,
kwargs: PigLatinKwargs,
) -> PolarsResult<Series> {
use rayon::prelude::*;
let ca = inputs[0].utf8()?;
let ca = inputs[0].str()?;

if context.parallel() {
let out: Utf8Chunked =
let out: StringChunked =
ca.apply_to_buffer(|value, output| pig_latin_str(value, kwargs.capitalize, output));
Ok(out.into_series())
} else {
Expand All @@ -82,7 +82,7 @@ fn pig_latinnify_with_paralellism(
})
.collect();

Ok(Utf8Chunked::from_chunk_iter(ca.name(), chunks.into_iter().flatten()).into_series())
Ok(StringChunked::from_chunk_iter(ca.name(), chunks.into_iter().flatten()).into_series())
})
}
}
Expand All @@ -96,8 +96,8 @@ fn jaccard_similarity(inputs: &[Series]) -> PolarsResult<Series> {

#[polars_expr(output_type=Float64)]
fn hamming_distance(inputs: &[Series]) -> PolarsResult<Series> {
let a = inputs[0].utf8()?;
let b = inputs[1].utf8()?;
let a = inputs[0].str()?;
let b = inputs[1].str()?;
let out: UInt32Chunked =
arity::binary_elementwise_values(a, b, crate::distances::naive_hamming_dist);
Ok(out.into_series())
Expand Down Expand Up @@ -145,11 +145,11 @@ pub struct MyKwargs {
/// If you want to accept `kwargs`. You define a `kwargs` argument
/// on the second position in you plugin. You can provide any custom struct that is deserializable
/// with the pickle protocol (on the rust side).
#[polars_expr(output_type=Utf8)]
#[polars_expr(output_type=String)]
fn append_kwargs(input: &[Series], kwargs: MyKwargs) -> PolarsResult<Series> {
let input = &input[0];
let input = input.cast(&DataType::Utf8)?;
let ca = input.utf8().unwrap();
let input = input.cast(&DataType::String)?;
let ca = input.str().unwrap();

Ok(ca
.apply_to_buffer(|val, buf| {
Expand Down
2 changes: 1 addition & 1 deletion pyo3-polars-derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pyo3-polars-derive"
version = "0.3.0"
version = "0.4.0"
edition = "2021"
license = "MIT"
readme = "README.md"
Expand Down
4 changes: 2 additions & 2 deletions pyo3-polars/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pyo3-polars"
version = "0.9.0"
version = "0.10.0"
edition = "2021"
license = "MIT"
readme = "../README.md"
Expand All @@ -17,7 +17,7 @@ polars-ffi = { workspace = true, optional = true }
polars-lazy = { workspace = true, optional = true }
polars-plan = { workspace = true, optional = true }
pyo3 = "0.20.0"
pyo3-polars-derive = { version = "0.3.0", path = "../pyo3-polars-derive", optional = true }
pyo3-polars-derive = { version = "0.4.0", path = "../pyo3-polars-derive", optional = true }
serde = { version = "1", optional = true }
serde-pickle = { version = "1", optional = true }
thiserror = "1"
Expand Down

0 comments on commit e39357c

Please sign in to comment.