-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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: Properly broadcast list arithmetic #18858
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #18858 +/- ##
==========================================
+ Coverage 79.87% 79.89% +0.02%
==========================================
Files 1519 1519
Lines 205839 205852 +13
Branches 2898 2898
==========================================
+ Hits 164416 164475 +59
+ Misses 40875 40829 -46
Partials 548 548 ☔ View full report in Codecov by Sentry. |
@@ -688,16 +688,6 @@ def test_list_arithmetic_nulls(a: list[Any], b: list[Any], expected: list[Any]) | |||
|
|||
|
|||
def test_list_arithmetic_error_cases() -> None: | |||
# Different series length: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think some of these tests are necessary? E.g. pl.Series([[1, 2], [3, 4]]) + pl.Series([[1, 1], [2, 2], [3, 4]])
should complain.
(Separately I am honestly not super-excited about semantics of single-item Series working this way, but I guess that's how literals work? So if that design decision has already been made, oh well.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or rather, some variations of existing tests should still be there, by tweaking existing assertions instead of deleting them.
import polars as pl | ||
|
||
|
||
def test_literal_broadcast_list() -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should also test eager operations in addition to lazy operations, e.g. df.get_column("A") + lit
, it sometimes hits different code paths for each when doing arithmetic, so you get different bugs.
I would also suggest adding a test where the literal is a different type than the list, e.g. a Int64
, and again testing both lazy and eager (casting definitely works differently).
Thank you @itamarst I made a naive copy of the I will close this as you are working this area already. |
I'm not working on the same thing though, so other than merge conflicts this seems worth continuing. |
But if you don't want to finish it, I can finish it up. |
ref: #18831
It seems like I just needed to copy the
broadcast_array()
impl from #18851