Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiplication by const raises (left == right) assert exception #6017

Closed
2 tasks done
s-b90 opened this issue Jan 3, 2023 · 1 comment · Fixed by #6036
Closed
2 tasks done

Multiplication by const raises (left == right) assert exception #6017

s-b90 opened this issue Jan 3, 2023 · 1 comment · Fixed by #6036
Labels
bug Something isn't working python Related to Python Polars

Comments

@s-b90
Copy link

s-b90 commented Jan 3, 2023

Polars version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of Polars.

Issue description

When filtering a colum in agg expression and after filtering we have 0 values, diff + multiplication may raise

pyo3_runtime.PanicException: assertion failed: `(left == right)`
 left: `0`,
right: `1`.

Note that if we moved * 1000 all works as expected:

pl.DataFrame({'col_to_groupby': [2], 'time': [1672740910.967138],  'col3': [1]}).groupby('col_to_groupby').agg(
   (pl.col('time').filter(pl.col('col3') == 0).diff().fill_null(strategy='zero')
   .diff().fill_null(strategy='zero') * 1000).mean().alias('fwd_iat_ho_mean').alias('calc')
)

Reproducible example

import polars as pl

pl.DataFrame({'col_to_groupby': [2], 'time': [1672740910.967138],  'col3': [1]}).groupby('col_to_groupby').agg(
    (pl.col('time').filter(pl.col('col3') == 0).diff() * 1000).fill_null(strategy='zero')
    .diff().fill_null(strategy='zero').mean().alias('calc')
)
pyo3_runtime.PanicException: assertion failed: `(left == right)`
  left: `0`,
 right: `1`

Expected behavior

Computation should return:

col_to_groupby calc
i64 f64
2 null

Installed versions

---Version info---
Polars: 0.15.11
Index type: UInt32
Platform: Linux-5.15.0-56-generic-x86_64-with-glibc2.35
Python: 3.8.16 (default, Dec  7 2022, 01:12:06) 
[GCC 11.3.0]
---Optional dependencies---
pyarrow: 10.0.1
pandas: <not installed>
numpy: 1.22.3
fsspec: 2022.8.2
connectorx: <not installed>
xlsx2csv: <not installed>
matplotlib: <not installed>
None

@s-b90 s-b90 added bug Something isn't working python Related to Python Polars labels Jan 3, 2023
@ritchie46
Copy link
Member

Removing some red herrings:

(pl.DataFrame({
    'col_to_groupby': [2], 
    'time': [1672740910.967138], 
    'col3': [1]})
.groupby('col_to_groupby')
 .agg(
    (pl.col('time').filter(pl.col('col3') == 0).diff() * 1000)
    .diff().alias('calc')
))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working python Related to Python Polars
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants