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

refactor(python): Return correct temporal type from Rust in to_numpy #14353

Merged
merged 1 commit into from
May 10, 2024

Conversation

stinodego
Copy link
Member

@stinodego stinodego commented Feb 7, 2024

Ref #14334

... as opposed to returning an integer array and then creating a view afterwards.

@github-actions github-actions bot added internal An internal refactor or improvement python Related to Python Polars labels Feb 7, 2024
@stinodego stinodego mentioned this pull request Feb 7, 2024
14 tasks
@stinodego stinodego marked this pull request as ready for review February 7, 2024 23:00
@ritchie46
Copy link
Member

Couldn't we reuse the integer code branches? It feels a bit wasteful (code bloat wise).

@stinodego
Copy link
Member Author

stinodego commented Feb 9, 2024

Couldn't we reuse the integer code branches? It feels a bit wasteful (code bloat wise).

We cannot reuse those because they return floats.

This could be a little bit less wasteful if we had a way to create a Datetime view of an existing integer array, similar to what we have in Python right now. But I don't think the difference will be significant.

I think you were planning to add a view-type functionality to our Rust to_numpy though, right? So maybe we wait for that and see if we can do this more efficiently.

@ritchie46
Copy link
Member

Alright. @stinodego can you refactor this one with the new array views? We could probably remove the old view completely.

@stinodego stinodego marked this pull request as draft February 12, 2024 16:52
@stinodego stinodego marked this pull request as ready for review May 9, 2024 22:59
@stinodego stinodego requested a review from reswqa as a code owner May 9, 2024 22:59
@stinodego
Copy link
Member Author

stinodego commented May 9, 2024

Alright. @stinodego can you refactor this one with the new array views? We could probably remove the old view completely.

The old view has now been removed in a different PR. It would still be nice to support creating views with different dtypes in Rust, e.g. a datetime64[ns] view, which seems to be possible. But that can be done in a different PR.

This PR is about the path with nulls, which requires copying the data. Technically we can create an i64 array and then create a view afterwards, but just creating the correct array type right away seems more sensible.

Copy link

codecov bot commented May 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.95%. Comparing base (b2291b9) to head (1515087).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14353      +/-   ##
==========================================
- Coverage   80.96%   80.95%   -0.02%     
==========================================
  Files        1386     1386              
  Lines      178492   178428      -64     
  Branches     2882     2877       -5     
==========================================
- Hits       144508   144438      -70     
- Misses      33492    33498       +6     
  Partials      492      492              

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

@stinodego stinodego merged commit 9a3deb3 into main May 10, 2024
17 of 18 checks passed
@stinodego stinodego deleted the np-temporal branch May 10, 2024 15:14
Wouittone pushed a commit to Wouittone/polars that referenced this pull request Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal An internal refactor or improvement python Related to Python Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants