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

"Cannot apply operation on arrays of different lengths" panic occurs when add two Series have defferent length #16978

Closed
2 tasks done
eitsupi opened this issue Jun 16, 2024 · 0 comments · Fixed by #16986
Closed
2 tasks done
Assignees
Labels
accepted Ready for implementation bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars

Comments

@eitsupi
Copy link
Contributor

eitsupi commented Jun 16, 2024

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, 2]) + pl.Series([1, 2, 3])

Log output

thread '<unnamed>' panicked at crates/polars-core/src/chunked_array/ops/arity.rs:764:14:
Cannot apply operation on arrays of different lengths
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/.local/lib/python3.10/site-packages/polars/series/series.py", line 1047, in __add__
    return self._arithmetic(other, "add", "add_<>")
  File "/home/user/.local/lib/python3.10/site-packages/polars/series/series.py", line 998, in _arithmetic
    return self._from_pyseries(getattr(self._s, op_s)(other._s))
pyo3_runtime.PanicException: Cannot apply operation on arrays of different lengths

Issue description

Panic seems to occur when trying to add Series of different lengths.

Expected behavior

There needs to be an error, not a panic.

Installed versions

--------Version info---------
Polars:               0.20.31
Index type:           UInt32
Platform:             Linux-5.15.153.1-microsoft-standard-WSL2-x86_64-with-glibc2.35
Python:               3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]

----Optional dependencies----
adbc_driver_manager:  <not installed>
cloudpickle:          <not installed>
connectorx:           <not installed>
deltalake:            <not installed>
fastexcel:            <not installed>
fsspec:               <not installed>
gevent:               <not installed>
hvplot:               <not installed>
matplotlib:           <not installed>
nest_asyncio:         <not installed>
numpy:                <not installed>
openpyxl:             <not installed>
pandas:               <not installed>
pyarrow:              <not installed>
pydantic:             <not installed>
pyiceberg:            <not installed>
pyxlsb:               <not installed>
sqlalchemy:           <not installed>
torch:                <not installed>
xlsx2csv:             <not installed>
xlsxwriter:           <not installed>
@eitsupi eitsupi added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Jun 16, 2024
@eitsupi eitsupi changed the title "Cannot apply operation on arrays of different lengths" panic "Cannot apply operation on arrays of different lengths" panic occurs when add two Series have defferent length Jun 16, 2024
@ritchie46 ritchie46 self-assigned this Jun 16, 2024
@c-peters c-peters added the accepted Ready for implementation label Jun 16, 2024
@c-peters c-peters added this to Backlog Jun 16, 2024
@c-peters c-peters moved this to Done in Backlog Jun 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Ready for implementation bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants