-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Open
Labels
A-panicArea: code that results in panic exceptionsArea: code that results in panic exceptionsA-rollingP-mediumPriority: mediumPriority: mediumacceptedReady for implementationReady for implementationbugSomething isn't workingSomething isn't workingpythonRelated to Python PolarsRelated to Python Polars
Description
Checks
- I have checked that this issue has not already been reported.
- I have confirmed this bug exists on the latest version of Polars.
Reproducible example
import polars as pl
pl.Series([1])
out = s.rolling_sum(window_size=0)
print(out)
Log output
thread '<unnamed>' panicked at crates/polars-compute/src/rolling/mod.rs:54:23:
attempt to subtract with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
File "/home/denecker/my-polars/issue_23392/issue_window_0.py", line 3, in <module>
out = s.rolling_sum(window_size=0)
File "/home/denecker/polars/py-polars/polars/series/utils.py", line 106, in wrapper
return s.to_frame().select_seq(f(*args, **kwargs)).to_series()
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
File "/home/denecker/polars/py-polars/polars/dataframe/frame.py", line 9894, in select_seq
.collect(optimizations=QueryOptFlags._eager())
~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/denecker/polars/py-polars/polars/_utils/deprecation.py", line 97, in wrapper
return function(*args, **kwargs)
File "/home/denecker/polars/py-polars/polars/lazyframe/opt_flags.py", line 330, in wrapper
return function(*args, **kwargs)
File "/home/denecker/polars/py-polars/polars/lazyframe/frame.py", line 2332, in collect
return wrap_df(ldf.collect(engine, callback))
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
pyo3_runtime.PanicException: attempt to subtract with overflow
Issue description
Some/most rolling aggregates raise a Panic when window_size=0
. All variants to be investigated.
Expected behavior
Same output as for an empty series.
Installed versions
--------Version info---------
Polars: 1.31.0
Index type: UInt32
Platform: Linux-5.15.167.4-microsoft-standard-WSL2-x86_64-with-glibc2.35
Python: 3.13.3 (main, Apr 29 2025, 12:20:45) [GCC 11.4.0]
LTS CPU: False
----Optional dependencies----
Azure CLI <not installed>
adbc_driver_manager 1.6.0
altair 5.5.0
azure.identity <not installed>
boto3 1.38.27
cloudpickle 3.1.1
connectorx 0.4.3
deltalake 1.0.2
fastexcel 0.14.0
fsspec 2025.5.1
gevent 25.5.1
google.auth 2.40.3
great_tables 0.17.0
matplotlib 3.10.3
numpy 2.2.5
openpyxl 3.1.5
pandas 2.2.3
polars_cloud 0.0.9
pyarrow 20.0.0
pydantic 2.11.7
pyiceberg 0.9.1
sqlalchemy 2.0.41
torch 2.7.1+cu126
xlsx2csv 0.8.4
xlsxwriter <not installed>
Metadata
Metadata
Assignees
Labels
A-panicArea: code that results in panic exceptionsArea: code that results in panic exceptionsA-rollingP-mediumPriority: mediumPriority: mediumacceptedReady for implementationReady for implementationbugSomething isn't workingSomething isn't workingpythonRelated to Python PolarsRelated to Python Polars