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

Redundant cast inside expression changes result in 0.20.23 #15952

Closed
2 tasks done
lukeshingles opened this issue Apr 29, 2024 · 2 comments
Closed
2 tasks done

Redundant cast inside expression changes result in 0.20.23 #15952

lukeshingles opened this issue Apr 29, 2024 · 2 comments
Labels
bug Something isn't working P-medium Priority: medium python Related to Python Polars

Comments

@lukeshingles
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({"x": range(5)})
print(df.select((pl.col("x") * 1.0e9 / 10)))
print(df.select((pl.col("x") * 1.0e9 / 10).cast(pl.Float64)))

Log output

shape: (5, 1)
┌─────┐
│ x   │
│ --- │
│ f64 │
╞═════╡
│ 0.0 │
│ 1e8 │
│ 2e8 │
│ 3e8 │
│ 4e8 │
└─────┘
shape: (5, 1)
┌──────┐
│ x    │
│ ---  │
│ f64  │
╞══════╡
│ 0.0  │
│ 1e8  │
│ 2e8  │
│ null │
│ null │

Issue description

This seems to be some kind of calculation range issue that gets triggered by the integer in the expression (replacing 10 with 10.0 prevents the issue) and the cast to float as part of the expression, which should not change the result, since the column resulting from the expression is already Float64.

Expected behavior

In 0.20.22, the two DataFrames as equal, as expected.

Installed versions

--------Version info---------
Polars:               0.20.23
Index type:           UInt32
Platform:             macOS-14.4.1-arm64-arm-64bit
Python:               3.12.3 (main, Apr  9 2024, 08:09:14) [Clang 15.0.0 (clang-1500.3.9.4)]

----Optional dependencies----
adbc_driver_manager:  <not installed>
cloudpickle:          <not installed>
connectorx:           <not installed>
deltalake:            <not installed>
fastexcel:            <not installed>
fsspec:               <not installed>
gevent:               24.2.1
hvplot:               <not installed>
matplotlib:           3.8.4
nest_asyncio:         1.6.0
numpy:                1.26.4
openpyxl:             <not installed>
pandas:               2.2.2
pyarrow:              16.0.0
pydantic:             <not installed>
pyiceberg:            <not installed>
pyxlsb:               <not installed>
sqlalchemy:           <not installed>
xlsx2csv:             <not installed>
xlsxwriter:           <not installed>
@lukeshingles lukeshingles added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Apr 29, 2024
@lukeshingles
Copy link
Author

Sorry if this is a duplicate. This seems to be related to #15951, which I've confirmed also became an issue with polars 0.20.23.

@deanm0000 deanm0000 added A-dtype-categorical Area: categorical data type P-medium Priority: medium and removed needs triage Awaiting prioritization by a maintainer labels May 3, 2024
@c-peters c-peters removed the A-dtype-categorical Area: categorical data type label May 3, 2024
@lukeshingles
Copy link
Author

This is fixed in polars 0.20.24.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P-medium Priority: medium python Related to Python Polars
Projects
Status: Done
Development

No branches or pull requests

3 participants