fix(python): Address pl.from_epoch losing fractional seconds#26419
Open
alexander-beedie wants to merge 3 commits intopola-rs:mainfrom
Open
fix(python): Address pl.from_epoch losing fractional seconds#26419alexander-beedie wants to merge 3 commits intopola-rs:mainfrom
pl.from_epoch losing fractional seconds#26419alexander-beedie wants to merge 3 commits intopola-rs:mainfrom
Conversation
af04e69 to
fb3751b
Compare
pl.from_epoch was lossy for fractional secondspl.from_epoch was lossy for fractional seconds
pl.from_epoch was lossy for fractional secondspl.from_epoch being lossy for fractional seconds
pl.from_epoch being lossy for fractional secondspl.from_epoch losing fractional seconds
fb3751b to
7e730cf
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #26419 +/- ##
=======================================
Coverage 81.40% 81.41%
=======================================
Files 1795 1795
Lines 244990 244991 +1
Branches 3079 3079
=======================================
+ Hits 199443 199457 +14
+ Misses 44761 44748 -13
Partials 786 786 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
7e730cf to
e728bac
Compare
e728bac to
181c65b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
pl.from_epochfunction was forcing a cast to Int64 during calculation, despite accepting both integer and float values.This led to lossy conversion of values with fractional seconds, as well as inconsistent rounding of seconds for negative values (dates before 1970). Results for integer input remain unchanged, but float input is now calculated correctly (also, the type signature was incomplete and has also been updated).
Example
Before
(lossy: fractional seconds discarded/truncated)
After
(fixed: fractional seconds converted/preserved)
Note
from_epochshould probably have two unit parameters - the unit of the input and the desired unit of the output, as there's no particular reason to link input/output units given the presence of fractional seconds.I might see if there's a backwards-compatible way to implement that in a future PR (as this one doesn't solve the related issue of fractional days being forced to
Date- you might have 1.5 days and want it converted toDatetime("ms"), for example. Currently you have to scale to seconds and then convert to do this) 🤔