fix(python): Preserve Duration type in timedelta multiplication#26438
Open
Zakir032002 wants to merge 2 commits intopola-rs:mainfrom
Open
fix(python): Preserve Duration type in timedelta multiplication#26438Zakir032002 wants to merge 2 commits intopola-rs:mainfrom
Zakir032002 wants to merge 2 commits intopola-rs:mainfrom
Conversation
Handle timedelta multiplication in both __mul__ and __rmul__ to preserve Duration type instead of casting to float. Fixes datetime/float encoding round-trips for time series analysis. Changes: - Added timedelta check in Series.__mul__() before _arithmetic fallback - Added timedelta check in Series.__rmul__() for reverse multiplication - Both use F.lit(timedelta) to preserve type information via expression engine Fixes pola-rs#26205
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #26438 +/- ##
==========================================
- Coverage 81.02% 81.00% -0.02%
==========================================
Files 1782 1782
Lines 243116 243120 +4
Branches 3078 3080 +2
==========================================
- Hits 196980 196940 -40
- Misses 45333 45375 +42
- Partials 803 805 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
orlp
requested changes
Feb 5, 2026
Member
orlp
left a comment
There was a problem hiding this comment.
I don't think this should be fixed by adding a hack in the Python code. Can you trace where the current multiplication implementation goes and fix it there?
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.
Handle timedelta multiplication in both mul and rmul to preserve
Duration type instead of silently casting to float. This fixes
datetime/float encoding round-trips commonly used in time-series analysis.
Changes:
_arithmetic fallback
multiplication
via the expression engine
Fixes #26205
minimal, and consistent with the existing codebase.