ion-elgreco / polars-distance

Polars plugin for pairwise distance functions
https://ion-elgreco.github.io/polars-distance/
MIT License
43 stars 5 forks source link

Does this support `pl.lit`? #24

Open clouds56 opened 2 days ago

clouds56 commented 2 days ago

In this example.

df_test = pl.DataFrame({
  'a1': ['test1', 'hello', 'test1', 'hello', 'test1', 'hello'],
})
df_test.select(
  d = pld.col('a1').dist_str.levenshtein(pl.lit('testaa'))
)

it returns

shape: (1, 1)
┌─────┐
│ d   │
│ --- │
│ u32 │
╞═════╡
│ 2   │
└─────┘

And in a more complex real world example, it panics with

panicked at /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/polars-core-0.38.3/src/utils/mod.rs:654:9:
assertion `left == right` failed: expected arrays of the same length
  left: 6
 right: 1
ion-elgreco commented 2 days ago

I am missing some optimization paths that checks the length of lhs or rhs. Don't really have time to fix this at the moment, so open to a PR that resolves this