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(python): Raise if pass a negative n into clear #15432

Merged
merged 2 commits into from
Apr 3, 2024

Conversation

reswqa
Copy link
Collaborator

@reswqa reswqa commented Apr 2, 2024

This aligns the behavior of series.clear(-1) and df.clear(-1).

NB. Before this change, the error of df.clear(-1) is raised from the extend_constant(pass a negative n), I think a more explicit error would be nice.

The only difference is that for an empty series, passing a negative n does not throw an error before this change. I feel like it makes the function behave a bit more predictable if we reject n < 0 outright, WDYT?

This fixes #15421.

@github-actions github-actions bot added fix Bug fix python Related to Python Polars labels Apr 2, 2024
Copy link

codecov bot commented Apr 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.13%. Comparing base (758b55a) to head (bab7462).
Report is 9 commits behind head on main.

❗ Current head bab7462 differs from pull request most recent head 0402126. Consider uploading reports for the commit 0402126 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15432      +/-   ##
==========================================
- Coverage   81.13%   81.13%   -0.01%     
==========================================
  Files        1362     1362              
  Lines      174802   174824      +22     
  Branches     2531     2532       +1     
==========================================
+ Hits       141825   141842      +17     
- Misses      32493    32498       +5     
  Partials      484      484              

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

@reswqa reswqa marked this pull request as ready for review April 2, 2024 06:22
Copy link
Member

@stinodego stinodego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I made a minor update to the error message formatting.

@stinodego stinodego merged commit 7fa8a3e into pola-rs:main Apr 3, 2024
12 checks passed
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.clear(-1) doesn't have the same behavior for Series and DataFrame
2 participants