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, rust): Block rounding/truncating to negative durations #15175

Merged
merged 1 commit into from
Mar 21, 2024

Conversation

rob-sil
Copy link
Contributor

@rob-sil rob-sil commented Mar 20, 2024

Polars will currently round dates and datetimes to negative durations:

In [16]: pl.Series([datetime(2020, 2, 15)]).dt.round('-1mo')
Out[16]:
shape: (1,)
Series: '' [datetime[μs]]
[
        2020-02-01 00:00:00
]

(Except not during development where negative durations hit a debug_assert.)

This PR disables that behavior for both rounding and truncating to negative durations, as discussed in #12597

@rob-sil rob-sil changed the title Block rounding/truncating to negative durations fix(python, rust): Block rounding/truncating to negative durations Mar 20, 2024
@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Mar 20, 2024
Copy link
Collaborator

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one, thanks @rob-sil !

@MarcoGorelli
Copy link
Collaborator

Merging then, as there's been no objections - let's take things forwards in the other PR!

@MarcoGorelli MarcoGorelli merged commit e6f7cb5 into pola-rs:main Mar 21, 2024
25 checks passed
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 rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants