Skip to content

TST: add tests for Series/DF logical operations nan propagation #29531

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

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions pandas/tests/frame/test_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,20 @@ def test_logical_with_nas(self):
expected = Series([True, True])
tm.assert_series_equal(result, expected)

@pytest.mark.parametrize(
"A, B, C",
Copy link
Member

Choose a reason for hiding this comment

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

Can you name these "left, right, expected"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, @mroeschke - done.

[
([True, False, np.nan], [True, False, True], [True, False, False]),
([True, False, True], [True, False, np.nan], [True, False, True]),
],
)
def test_logical_operators_nans(self, A, B, C):
# GH 13896
result = DataFrame(A) | DataFrame(B)
expected = DataFrame(C)

tm.assert_frame_equal(result, expected)


class TestDataFrameOperators:
@pytest.mark.parametrize(
Expand Down
14 changes: 14 additions & 0 deletions pandas/tests/series/test_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ def test_logical_operators_bool_dtype_with_empty(self):
expected = s_tft
tm.assert_series_equal(res, expected)

@pytest.mark.parametrize(
"A, B, C",
[
([True, False, np.nan], [True, False, True], [True, False, False]),
([True, False, True], [True, False, np.nan], [True, False, True]),
],
)
def test_logical_operators_nans(self, A, B, C):
# GH 13896
result = Series(A) | Series(B)
expected = Series(C)

tm.assert_series_equal(result, expected)

def test_logical_operators_int_dtype_with_int_dtype(self):
# GH#9016: support bitwise op for integer types

Expand Down