Skip to content

CLN: parametrize test_nat_comparisons #37195

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 4 commits into from
Nov 4, 2020
Merged
Changes from all commits
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
40 changes: 22 additions & 18 deletions pandas/tests/arithmetic/test_datetime64.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,26 @@ class TestDatetime64SeriesComparison:
)
@pytest.mark.parametrize("reverse", [True, False])
@pytest.mark.parametrize("dtype", [None, object])
def test_nat_comparisons(self, dtype, index_or_series, reverse, pair):
@pytest.mark.parametrize(
"op, expected",
[
(operator.eq, Series([False, False, True])),
(operator.ne, Series([True, True, False])),
(operator.lt, Series([False, False, False])),
(operator.gt, Series([False, False, False])),
(operator.ge, Series([False, False, True])),
(operator.le, Series([False, False, True])),
],
)
def test_nat_comparisons(
self,
dtype,
index_or_series,
reverse,
pair,
op,
expected,
):
box = index_or_series
l, r = pair
if reverse:
Expand All @@ -182,25 +201,10 @@ def test_nat_comparisons(self, dtype, index_or_series, reverse, pair):

left = Series(l, dtype=dtype)
right = box(r, dtype=dtype)
# Series, Index

expected = Series([False, False, True])
tm.assert_series_equal(left == right, expected)
result = op(left, right)

expected = Series([True, True, False])
tm.assert_series_equal(left != right, expected)

expected = Series([False, False, False])
tm.assert_series_equal(left < right, expected)

expected = Series([False, False, False])
tm.assert_series_equal(left > right, expected)

expected = Series([False, False, True])
tm.assert_series_equal(left >= right, expected)

expected = Series([False, False, True])
tm.assert_series_equal(left <= right, expected)
tm.assert_series_equal(result, expected)

def test_comparison_invalid(self, tz_naive_fixture, box_with_array):
# GH#4968
Expand Down