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

feat(python): Infer time_unit in pl.duration when nanoseconds is specified #14987

Merged
merged 6 commits into from
Mar 20, 2024

Conversation

cojmeister
Copy link
Contributor

@cojmeister cojmeister commented Mar 11, 2024

Closes #14751

  • Made time_unit optional
  • If nanoseconds is provided and time unit set to None, then time unit will be automatically set to nanoseconds
  • If microseconds is provided (and nanoseconds isn't) and time_unit set to None, then time unit will be automatically set to microseconds
  • If milliseconds is provided (and the other two aren't) and time_unit set to None, then time unit will be automatically set to milliseconds
  • If none of the above are provided, and time_unit is not provided, it will be set to microseconds - 'us'

@stinodego I hope this is what you meant

@stinodego stinodego changed the title Feature/make time unit optional feat(python): Infer time_unit in pl.duration when nanoseconds is specified Mar 14, 2024
@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature python Related to Python Polars labels Mar 14, 2024
Copy link
Member

@stinodego stinodego left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

We don't want to infer ms time unit when a millisecond is specified. The logic for inference should be: if no time unit is specified, and if nanosecond is specified, use ns. Otherwise, use us.

Please also add a test that showcases this new functionality.

Copy link

codecov bot commented Mar 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.05%. Comparing base (e204928) to head (ed60d83).
Report is 1 commits behind head on main.

❗ Current head ed60d83 differs from pull request most recent head d1ad911. Consider uploading reports for the commit d1ad911 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14987      +/-   ##
==========================================
- Coverage   81.21%   81.05%   -0.17%     
==========================================
  Files        1348     1338      -10     
  Lines      175318   173832    -1486     
  Branches     2506     2458      -48     
==========================================
- Hits       142390   140892    -1498     
- Misses      32448    32473      +25     
+ Partials      480      467      -13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor Author

@cojmeister cojmeister left a comment

Choose a reason for hiding this comment

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

Done with the changes

@stinodego stinodego force-pushed the feature/make-time_unit-optional branch from ed60d83 to d1ad911 Compare March 20, 2024 08:39
Copy link
Member

@stinodego stinodego left a comment

Choose a reason for hiding this comment

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

Thanks!

@stinodego stinodego merged commit 77b8529 into pola-rs:main Mar 20, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or an improvement of an existing feature python Related to Python Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Infer time_unit in pl.duration when nanoseconds is specified
2 participants