Skip to content

Commit

Permalink
first working version with test
Browse files Browse the repository at this point in the history
  • Loading branch information
barak1412 committed Sep 25, 2024
1 parent 39d63aa commit d0b0385
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
11 changes: 1 addition & 10 deletions crates/polars-core/src/chunked_array/comparison/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -720,22 +720,13 @@ where
BooleanChunked::full(PlSmallStr::EMPTY, value, a.len())
} else {
let (a, b) = align_chunks_binary(a, b);
let mut out = a
let out = a
.fields_as_series()
.iter()
.zip(b.fields_as_series().iter())
.map(|(l, r)| op(l, r))
.reduce(reduce)
.unwrap();
if a.null_count() > 0 || b.null_count() > 0 {
let mut a = a.into_owned();
a.zip_outer_validity(&b);
unsafe {
for (arr, a) in out.downcast_iter_mut().zip(a.downcast_iter()) {
arr.set_validity(a.validity().cloned())
}
}
}
out
}
}
Expand Down
24 changes: 24 additions & 0 deletions py-polars/tests/unit/operations/test_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,30 @@ def test_missing_equality_on_bools() -> None:
]


def test_struct_equality_18870() -> None:
s = pl.Series([{"a": 1}, None])

# eq
result = s.eq(s).to_list()
expected = [True, None]
assert result == expected

# ne
result = s.ne(s).to_list()
expected = [False, None]
assert result == expected

# eq_missing
result = s.eq_missing(s).to_list()
expected = [True, True]
assert result == expected

# ne_missing
result = s.ne_missing(s).to_list()
expected = [False, False]
assert result == expected


def isnan(x: Any) -> bool:
return isinstance(x, float) and math.isnan(x)

Expand Down

0 comments on commit d0b0385

Please sign in to comment.