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: add all methods of RPolarsExpr to RPolarsSeries #831

Merged
merged 8 commits into from
Feb 23, 2024

Conversation

eitsupi
Copy link
Collaborator

@eitsupi eitsupi commented Feb 22, 2024

Instead of the experimental <Series>$expr$<method>, we can call methods that exist only in Expr with <Series>$<method>.

@eitsupi eitsupi marked this pull request as ready for review February 22, 2024 16:27
@eitsupi eitsupi added this to the 0.14 milestone Feb 22, 2024
@eitsupi eitsupi mentioned this pull request Feb 22, 2024
@eitsupi
Copy link
Collaborator Author

eitsupi commented Feb 23, 2024

@etiennebacher I would like to merge this for a new release. Could you help me merge it?

@etiennebacher
Copy link
Collaborator

I can review in a couple of hours

Copy link
Collaborator

@etiennebacher etiennebacher left a comment

Choose a reason for hiding this comment

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

That looks good to me, thanks!

Now that the method dispatch is made automatically, can you remove the old implementation of the methods for Series? For example it's no longer necessary to implement Series_add ourselves. Note however that some methods cannot be removed because they should return a scalar and not a Series (e.g $sum(), $mean()...)

@eitsupi
Copy link
Collaborator Author

eitsupi commented Feb 23, 2024

Now that the method dispatch is made automatically, can you remove the old implementation of the methods for Series?

Of course it is possible, but most of the existing methods look like thin wrappers for Rust Polars, so I think it might as well be left as they are.

In other words, what is here needs to be implemented on the Rust side as before, but the rest needs to be brought in from Expr.
https://docs.rs/polars/0.37.0/polars/series/struct.Series.html

Copy link
Collaborator

@etiennebacher etiennebacher left a comment

Choose a reason for hiding this comment

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

I get that some methods must be implemented in Rust because either they don't have equivalent in Expr or the Expr method would return a Series instead of a scalar. But other Series methods could simply be removed from the Rust and R sides and nothing would change, e.g $floor(), $ceiling().

I don't want this to be a blocker for this PR, but I think we should get rid of them to reduce the codebase.

@etiennebacher
Copy link
Collaborator

Apart from that, thank you for this PR, it's super useful to dispatch methods like this

@eitsupi
Copy link
Collaborator Author

eitsupi commented Feb 23, 2024

Thanks for reviewing this. I will merge it and release it.

@eitsupi eitsupi merged commit 47dd5ca into main Feb 23, 2024
18 checks passed
@eitsupi eitsupi deleted the series-methods-from-expr branch February 23, 2024 12:54
@eitsupi
Copy link
Collaborator Author

eitsupi commented Feb 23, 2024

Sorry, the commit comment for the merge commit was broken due to browser behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants