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): Support duplicate expression names when calling ufuncs #17641

Merged
merged 6 commits into from
Jul 16, 2024

Conversation

itamarst
Copy link
Contributor

Fixes #17472

@@ -292,20 +292,34 @@ def __array_ufunc__(
is_custom_ufunc = getattr(ufunc, "signature") is not None # noqa: B009
num_expr = sum(isinstance(inp, Expr) for inp in inputs)
exprs = [
(inp, Expr, i) if isinstance(inp, Expr) else (inp, None, i)
(inp, True, i) if isinstance(inp, Expr) else (inp, False, i)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just a small cleanup suggested by @deanm0000

@itamarst
Copy link
Contributor Author

Thanks to @deanm0000 for helping to figure out the solution.

return root_expr.map_batches(
function, is_elementwise=False
).meta.undo_aliases()
return root_expr.map_batches(function, is_elementwise=True).meta.undo_aliases()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think my original reason for having undo_aliases here was that I was trying to interact with the struct's inner columns by name but then abandoned that for square brackets and forgot to take out this undo_aliases so it serves no real purpose and it is good to take it out......I think

@itamarst itamarst requested a review from deanm0000 July 15, 2024 15:37
Copy link

codecov bot commented Jul 15, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 2 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@e570e77). Learn more about missing BASE report.
Report is 9 commits behind head on main.

Files Patch % Lines
py-polars/polars/expr/expr.py 83.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #17641   +/-   ##
=======================================
  Coverage        ?   80.71%           
=======================================
  Files           ?     1485           
  Lines           ?   195493           
  Branches        ?     2785           
=======================================
  Hits            ?   157801           
  Misses          ?    37179           
  Partials        ?      513           

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

@ritchie46 ritchie46 merged commit 4b7e2bd into pola-rs:main Jul 16, 2024
14 checks passed
@itamarst itamarst deleted the 17472-duplicate-fields branch July 17, 2024 13:06
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Numpy functions with more than one argument cannot have same column in multiple arguments
4 participants