-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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(rust): Improve error message for mismatched input lengths #22091
base: main
Are you sure you want to change the base?
Conversation
9f93d63
to
c4d509a
Compare
b12533e
to
a27d5b1
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #22091 +/- ##
=======================================
Coverage 80.88% 80.89%
=======================================
Files 1641 1641
Lines 236509 236555 +46
Branches 2701 2705 +4
=======================================
+ Hits 191307 191351 +44
Misses 44563 44563
- Partials 639 641 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error needs to be propagated up. We don't want the unwrap because that is still a panic.
567414c
to
2f7122f
Compare
…remove redundant validation - Propagate input length validation error using `PolarsResult` in `cov` and `pearson_corr`. - Removed redundant validation inside `CovState::new()` and `PearsonState::new()` since validation is already performed at the API boundary.
2f7122f
to
97db07e
Compare
@coastalwhite - error should now be propagated all the way. Also removed some assertions that seemed redundant. Let me know what you think |
Closes: #22080
Overview
This PR improves the error handling in corr and pearson_corr functions by replacing a panic assertion with a descriptive PolarsError::ComputeError.
Previously, when input Series to corr had mismatched lengths, Polars would panic with an unhelpful Rust assertion error.
This PR introduces a proper ComputeError with a clear and actionable message:
"Input Series to corr must have the same length, but got lengths {} and {}."
This improves the developer experience and allows for cleaner error propagation in the future.
Ouptut log
Notes
Removed redundant input length validation in CovState::new() and PearsonState::new() since the check is already performed in cov() and pearson_corr().