-
-
Notifications
You must be signed in to change notification settings - Fork 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: Return correct dtype for s.clear()
when dtype is Object
#15315
Conversation
Also, any reason we cannot simply do a length-0 slice and clone? That works too. Update: using slice method instead to prevent other errors. |
1737122
to
5ba3a3b
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #15315 +/- ##
==========================================
- Coverage 81.41% 81.36% -0.06%
==========================================
Files 1362 1364 +2
Lines 176734 176613 -121
Branches 2531 2526 -5
==========================================
- Hits 143896 143696 -200
- Misses 32354 32434 +80
+ Partials 484 483 -1 ☔ View full report in Codecov by Sentry. |
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.
Thanks, I think this is a good fix. But I don't know who wrote the original 'hack' - so I'm not sure their use case is now covered. @ritchie46 could you take a quick look?
crates/polars-core/src/series/mod.rs
Outdated
self.clone() | ||
} else { | ||
// SAFETY: we can always take zero elements | ||
unsafe { self.take_slice_unchecked(&[]).clone() } |
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.
This works. Though this is not worth doing unsafe. Can we use self.take
.
I also wonder why we need to clone
afterwards? 🤔
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.
Can do. Out of curiosity, is this path a bit simpler/faster than the standard dtype path of going through full_null
with zero elements? We could just remove all the if logic and just return an empty slice for all dtypes.
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.
Ahh unfortunately that breaks pl.Array
. I'll keep the special object logic in there.
@ritchie46 used Edit: this broke some memory alignment on Windows build for some reason. |
Ok, no more errors. |
|
@ritchie46 this one passes now and uses |
Resolves #15303.
I think this is a good way to do it? @stinodego will need your input here.