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

fix: Incorrect scale used in log and exp for Decimal type #20888

Merged
merged 1 commit into from
Jan 24, 2025

Conversation

lukemanley
Copy link
Contributor

from decimal import Decimal as D
import polars as pl

df = pl.Series("a", [D("1.0")]).to_frame()

df.with_columns(
    pl.col("a").log().alias("a_log"),
    pl.col("a").exp().alias("a_exp"),
)

BEFORE:

┌──────────────┬──────────┬──────────────┐
│ a            ┆ a_log    ┆ a_exp        │
│ ---          ┆ ---      ┆ ---          │
│ decimal[*,1] ┆ f64      ┆ f64          │
╞══════════════╪══════════╪══════════════╡
│ 1.0          ┆ 2.302585 ┆ 22026.465795 │
└──────────────┴──────────┴──────────────┘

AFTER:

┌──────────────┬───────┬──────────┐
│ a            ┆ a_log ┆ a_exp    │
│ ---          ┆ ---   ┆ ---      │
│ decimal[*,1] ┆ f64   ┆ f64      │
╞══════════════╪═══════╪══════════╡
│ 1.0          ┆ 0.0   ┆ 2.718282 │
└──────────────┴───────┴──────────┘

@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Jan 24, 2025
Copy link

codecov bot commented Jan 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.73%. Comparing base (7ccb3ae) to head (6bb7135).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #20888   +/-   ##
=======================================
  Coverage   79.73%   79.73%           
=======================================
  Files        1566     1566           
  Lines      222591   222606   +15     
  Branches     2572     2572           
=======================================
+ Hits       177473   177496   +23     
+ Misses      44526    44518    -8     
  Partials      592      592           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@orlp orlp merged commit d9a5bb4 into pola-rs:main Jan 24, 2025
28 checks passed
@orlp
Copy link
Collaborator

orlp commented Jan 24, 2025

Thanks!

@lukemanley lukemanley deleted the decimal-log-exp branch January 25, 2025 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants