-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: add kwargs that are deserializable by user defined structs (#29)
- Loading branch information
Showing
17 changed files
with
269 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ Cargo.lock | |
.idea/ | ||
venv/ | ||
target/ | ||
rust-toolchain.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
mod distances; | ||
mod expressions; | ||
|
||
#[global_allocator] | ||
#[cfg(target_os = "linux")] | ||
static ALLOC: Jemalloc = Jemalloc; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,42 @@ | ||
import polars as pl | ||
from expression_lib import Language, Distance | ||
|
||
df = pl.DataFrame({ | ||
"names": ["Richard", "Alice", "Bob"], | ||
"moons": ["full", "half", "red"], | ||
"dist_a": [[12, 32, 1], [], [1, -2]], | ||
"dist_b": [[-12, 1], [43], [876, -45, 9]], | ||
"floats": [5.6, -1245.8, 242.224] | ||
}) | ||
df = pl.DataFrame( | ||
{ | ||
"names": ["Richard", "Alice", "Bob"], | ||
"moons": ["full", "half", "red"], | ||
"dist_a": [[12, 32, 1], [], [1, -2]], | ||
"dist_b": [[-12, 1], [43], [876, -45, 9]], | ||
"floats": [5.6, -1245.8, 242.224], | ||
} | ||
) | ||
|
||
|
||
out = df.with_columns( | ||
pig_latin = pl.col("names").language.pig_latinnify(), | ||
pig_latin=pl.col("names").language.pig_latinnify(), | ||
).with_columns( | ||
hamming_dist = pl.col("names").dist.hamming_distance("pig_latin"), | ||
jaccard_sim = pl.col("dist_a").dist.jaccard_similarity("dist_b"), | ||
haversine = pl.col("floats").dist.haversine("floats", "floats", "floats", "floats"), | ||
hamming_dist=pl.col("names").dist.hamming_distance("pig_latin"), | ||
jaccard_sim=pl.col("dist_a").dist.jaccard_similarity("dist_b"), | ||
haversine=pl.col("floats").dist.haversine("floats", "floats", "floats", "floats"), | ||
appended_args=pl.col("names").language.append_args( | ||
float_arg=11.234, | ||
integer_arg=93, | ||
boolean_arg=False, | ||
string_arg="example", | ||
) | ||
) | ||
|
||
print(out) | ||
|
||
|
||
# Tests we can return errors from FFI by passing wrong types. | ||
try: | ||
out.with_columns( | ||
appended_args=pl.col("names").language.append_args( | ||
float_arg=True, | ||
integer_arg=True, | ||
boolean_arg=True, | ||
string_arg="example", | ||
)) | ||
except pl.ComputeError as e: | ||
assert "the plugin failed with message" in str(e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.