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 for incompatible array casting in series construction #17900

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tylerriccio33
Copy link
Contributor

@tylerriccio33 tylerriccio33 commented Jul 27, 2024

In #17743 constructing series objects from numpy arrays, when using a polars array dtype, may allow for unwanted coercion. For example, you may pass a polars int array to dtype and it may cast the numpy float array to int, which is obviously undesirable.

I debated throttling this behavior based on the strict argument, which is passed to the Series constructor. I decided not to allow an override to this edge case check since I (personally) would want this exception raised in all cases. If the core dev team thinks otherwise I can of course alter this.

The logic I wrote was for this specific edge case but there may be others I just am not thinking about. This is why I broke the logic out to a separate checking function.

Copy link

codecov bot commented Jul 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.51%. Comparing base (1f14e4a) to head (d34703f).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17900      +/-   ##
==========================================
- Coverage   80.51%   80.51%   -0.01%     
==========================================
  Files        1492     1492              
  Lines      196426   196435       +9     
  Branches     2813     2817       +4     
==========================================
+ Hits       158157   158162       +5     
- Misses      37748    37752       +4     
  Partials      521      521              

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

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.

1 participant