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

PanicException for Hist method #19998

Open
2 tasks done
BenGale93 opened this issue Nov 26, 2024 · 0 comments · May be fixed by #20016
Open
2 tasks done

PanicException for Hist method #19998

BenGale93 opened this issue Nov 26, 2024 · 0 comments · May be fixed by #20016
Labels
bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars

Comments

@BenGale93
Copy link

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

df = pl.DataFrame(
    {
        "floats": [
            9514.988509739183,
            30738.098872148617,
            41400.15705103004,
            49093.06982022727,
        ]
    }
)

result = df.lazy().select(pl.col("floats").hist(bin_count=50, include_breakpoint=True)).collect()

print(result)

Log output

thread '<unnamed>' panicked at crates/polars-ops/src/chunked_array/hist.rs:112:22:
index out of bounds: the len is 50 but the index is 50
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
  File "****/test.py", line 18, in <module>
    result = df.lazy().select(pl.col("floats").hist(bin_count=50, include_breakpoint=True)).collect()
  File "****/.venv/lib/python3.9/site-packages/polars/lazyframe/frame.py", line 2029, in collect
    return wrap_df(ldf.collect(callback))
pyo3_runtime.PanicException: index out of bounds: the len is 50 but the index is 50

Issue description

Only occurs in 1.15 as I've tested in 1.14 too.

If you set bin_count=49, it works.
If you delete 9514.988509739183 from the list, it also works.

Expected behavior

The histogram should be computed without a panic.

Installed versions

--------Version info---------
Polars:              1.15.0
Index type:          UInt32
Platform:            Linux-4.4.0-19041-Microsoft-x86_64-with-glibc2.31
Python:              3.9.20 (main, Oct 16 2024, 04:36:33) 
[Clang 18.1.8 ]
LTS CPU:             False

----Optional dependencies----
adbc_driver_manager  <not installed>
altair               <not installed>
boto3                1.35.36
cloudpickle          <not installed>
connectorx           <not installed>
deltalake            <not installed>
fastexcel            0.11.5
fsspec               2024.9.0
gevent               <not installed>
google.auth          <not installed>
great_tables         0.13.0
matplotlib           3.9.2
nest_asyncio         <not installed>
numpy                1.26.0
openpyxl             3.1.5
pandas               1.5.0
pyarrow              18.0.0
pydantic             2.8.0
pyiceberg            <not installed>
sqlalchemy           <not installed>
torch                <not installed>
xlsx2csv             <not installed>
xlsxwriter           3.2.0
@BenGale93 BenGale93 added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant