From 1fb45d846882a7b90a30832360d5d3672a904e65 Mon Sep 17 00:00:00 2001 From: ftrihardjo Date: Wed, 6 Jan 2021 08:35:29 +0700 Subject: [PATCH 1/8] pandas-dev issue #30699 --- pandas/tests/extension/test_datetime.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pandas/tests/extension/test_datetime.py b/pandas/tests/extension/test_datetime.py index 0fde1e8a2fdb8..36904b29dbe9b 100644 --- a/pandas/tests/extension/test_datetime.py +++ b/pandas/tests/extension/test_datetime.py @@ -162,6 +162,20 @@ def _compare_other(self, s, data, op_name, other): # with (some) integers, depending on the value. pass + def test_compare_with_Categorical(self): + result = pd.date_range("2020", periods=3) + expected = pd.Categorical(result) + assert result == expected + result = pd.date_range("2020", periods=3, tz="UTC") + expected = pd.Categorical(result) + assert result == expected + result = pd.timedelta_range("0 days", periods=3) + expected = pd.Categorical(result) + assert result == expected + result = pd.period_range("2020Q1", periods=3, freq="Q") + expected = pd.Categorical(result) + assert result == expected + class TestMissing(BaseDatetimeTests, base.BaseMissingTests): pass From bc390155aee4abfcb8952e55f0e607ab370d85d9 Mon Sep 17 00:00:00 2001 From: ftrihardjo Date: Wed, 6 Jan 2021 09:24:28 +0700 Subject: [PATCH 2/8] pandas-dev issue #30699 --- pandas/tests/extension/test_datetime.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/tests/extension/test_datetime.py b/pandas/tests/extension/test_datetime.py index 36904b29dbe9b..9be0a2ba6fd6f 100644 --- a/pandas/tests/extension/test_datetime.py +++ b/pandas/tests/extension/test_datetime.py @@ -165,16 +165,16 @@ def _compare_other(self, s, data, op_name, other): def test_compare_with_Categorical(self): result = pd.date_range("2020", periods=3) expected = pd.Categorical(result) - assert result == expected + assert (result == expected).all() result = pd.date_range("2020", periods=3, tz="UTC") expected = pd.Categorical(result) - assert result == expected + assert (result == expected).all() result = pd.timedelta_range("0 days", periods=3) expected = pd.Categorical(result) - assert result == expected + assert (result == expected).all() result = pd.period_range("2020Q1", periods=3, freq="Q") expected = pd.Categorical(result) - assert result == expected + assert (result == expected).all() class TestMissing(BaseDatetimeTests, base.BaseMissingTests): From da043acfc71102c5eed9597bd9c95ac27fcbc55f Mon Sep 17 00:00:00 2001 From: ftrihardjo Date: Wed, 6 Jan 2021 13:56:35 +0700 Subject: [PATCH 3/8] pandas-dev issue #30699 --- pandas/tests/extension/test_datetime.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/tests/extension/test_datetime.py b/pandas/tests/extension/test_datetime.py index 9be0a2ba6fd6f..5be8d2916b82d 100644 --- a/pandas/tests/extension/test_datetime.py +++ b/pandas/tests/extension/test_datetime.py @@ -165,16 +165,16 @@ def _compare_other(self, s, data, op_name, other): def test_compare_with_Categorical(self): result = pd.date_range("2020", periods=3) expected = pd.Categorical(result) - assert (result == expected).all() + assert all(result == expected) result = pd.date_range("2020", periods=3, tz="UTC") expected = pd.Categorical(result) - assert (result == expected).all() + assert all(result == expected) result = pd.timedelta_range("0 days", periods=3) expected = pd.Categorical(result) - assert (result == expected).all() + assert all(result == expected) result = pd.period_range("2020Q1", periods=3, freq="Q") expected = pd.Categorical(result) - assert (result == expected).all() + assert all(result == expected) class TestMissing(BaseDatetimeTests, base.BaseMissingTests): From 156b0cb69da895c20cec7340743a79f0ecc3013b Mon Sep 17 00:00:00 2001 From: ftrihardjo Date: Thu, 7 Jan 2021 09:31:49 +0700 Subject: [PATCH 4/8] pandas-dev issue #30699 --- pandas/tests/arrays/test_datetimelike.py | 18 ++++++++++++++++++ pandas/tests/extension/test_datetime.py | 14 -------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/pandas/tests/arrays/test_datetimelike.py b/pandas/tests/arrays/test_datetimelike.py index 7c093ebe00959..043347886a979 100644 --- a/pandas/tests/arrays/test_datetimelike.py +++ b/pandas/tests/arrays/test_datetimelike.py @@ -85,6 +85,24 @@ def test_compare_len1_raises(self): with pytest.raises(ValueError, match="Lengths must match"): idx <= idx[[0]] + def test_compare_with_Categorical(self): + result = pd.date_range("2020", periods=3) + expected = pd.Categorical(result) + assert all(result == expected) + assert not any(result != expected) + result = pd.date_range("2020", periods=3, tz="UTC") + expected = pd.Categorical(result) + assert all(result == expected) + assert not any(result != expected) + result = pd.timedelta_range("0 days", periods=3) + expected = pd.Categorical(result) + assert all(result == expected) + assert not any(result != expected) + result = pd.period_range("2020Q1", periods=3, freq="Q") + expected = pd.Categorical(result) + assert all(result == expected) + assert not any(result != expected) + @pytest.mark.parametrize("reverse", [True, False]) @pytest.mark.parametrize("as_index", [True, False]) def test_compare_categorical_dtype(self, arr1d, as_index, reverse, ordered): diff --git a/pandas/tests/extension/test_datetime.py b/pandas/tests/extension/test_datetime.py index 5be8d2916b82d..0fde1e8a2fdb8 100644 --- a/pandas/tests/extension/test_datetime.py +++ b/pandas/tests/extension/test_datetime.py @@ -162,20 +162,6 @@ def _compare_other(self, s, data, op_name, other): # with (some) integers, depending on the value. pass - def test_compare_with_Categorical(self): - result = pd.date_range("2020", periods=3) - expected = pd.Categorical(result) - assert all(result == expected) - result = pd.date_range("2020", periods=3, tz="UTC") - expected = pd.Categorical(result) - assert all(result == expected) - result = pd.timedelta_range("0 days", periods=3) - expected = pd.Categorical(result) - assert all(result == expected) - result = pd.period_range("2020Q1", periods=3, freq="Q") - expected = pd.Categorical(result) - assert all(result == expected) - class TestMissing(BaseDatetimeTests, base.BaseMissingTests): pass From 949cbd75400dd59bf2c14c14377cb0be47bb2115 Mon Sep 17 00:00:00 2001 From: ftrihardjo Date: Fri, 8 Jan 2021 07:28:50 +0700 Subject: [PATCH 5/8] pandas-dev issue #30699 --- pandas/tests/arrays/test_datetimelike.py | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/pandas/tests/arrays/test_datetimelike.py b/pandas/tests/arrays/test_datetimelike.py index 043347886a979..99cdc81695c9a 100644 --- a/pandas/tests/arrays/test_datetimelike.py +++ b/pandas/tests/arrays/test_datetimelike.py @@ -85,20 +85,8 @@ def test_compare_len1_raises(self): with pytest.raises(ValueError, match="Lengths must match"): idx <= idx[[0]] - def test_compare_with_Categorical(self): - result = pd.date_range("2020", periods=3) - expected = pd.Categorical(result) - assert all(result == expected) - assert not any(result != expected) - result = pd.date_range("2020", periods=3, tz="UTC") - expected = pd.Categorical(result) - assert all(result == expected) - assert not any(result != expected) - result = pd.timedelta_range("0 days", periods=3) - expected = pd.Categorical(result) - assert all(result == expected) - assert not any(result != expected) - result = pd.period_range("2020Q1", periods=3, freq="Q") + @pytest.mark.parametrize("result",[pd.date_range("2020", periods=3), pd.date_range("2020", periods=3, tz="UTC"), pd.timedelta_range("0 days", periods=3), pd.period_range("2020Q1", periods=3, freq="Q")]) + def test_compare_with_Categorical(self, result): expected = pd.Categorical(result) assert all(result == expected) assert not any(result != expected) From 613a3cba50e800e520fd0bf4675c5f962d591f70 Mon Sep 17 00:00:00 2001 From: ftrihardjo Date: Fri, 8 Jan 2021 07:59:18 +0700 Subject: [PATCH 6/8] pandas-dev issue #30699 --- pandas/tests/arrays/test_datetimelike.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pandas/tests/arrays/test_datetimelike.py b/pandas/tests/arrays/test_datetimelike.py index 99cdc81695c9a..26170ab513096 100644 --- a/pandas/tests/arrays/test_datetimelike.py +++ b/pandas/tests/arrays/test_datetimelike.py @@ -85,7 +85,15 @@ def test_compare_len1_raises(self): with pytest.raises(ValueError, match="Lengths must match"): idx <= idx[[0]] - @pytest.mark.parametrize("result",[pd.date_range("2020", periods=3), pd.date_range("2020", periods=3, tz="UTC"), pd.timedelta_range("0 days", periods=3), pd.period_range("2020Q1", periods=3, freq="Q")]) + @pytest.mark.parametrize( + "result", + [ + pd.date_range("2020", periods=3), + pd.date_range("2020", periods=3, tz="UTC"), + pd.timedelta_range("0 days", periods=3), + pd.period_range("2020Q1", periods=3, freq="Q") + ] + ) def test_compare_with_Categorical(self, result): expected = pd.Categorical(result) assert all(result == expected) From 3e717114afa74ef0f5e9f4c6450dfa737d2182f0 Mon Sep 17 00:00:00 2001 From: ftrihardjo Date: Fri, 8 Jan 2021 08:05:58 +0700 Subject: [PATCH 7/8] pandas-dev issue #30699 --- pandas/tests/arrays/test_datetimelike.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/arrays/test_datetimelike.py b/pandas/tests/arrays/test_datetimelike.py index 26170ab513096..a0b270224d30a 100644 --- a/pandas/tests/arrays/test_datetimelike.py +++ b/pandas/tests/arrays/test_datetimelike.py @@ -92,7 +92,7 @@ def test_compare_len1_raises(self): pd.date_range("2020", periods=3, tz="UTC"), pd.timedelta_range("0 days", periods=3), pd.period_range("2020Q1", periods=3, freq="Q") - ] + ], ) def test_compare_with_Categorical(self, result): expected = pd.Categorical(result) From 8a163a460bc5b1a4f46fae098fdd7f1d2c7cf8a8 Mon Sep 17 00:00:00 2001 From: ftrihardjo Date: Fri, 8 Jan 2021 08:12:37 +0700 Subject: [PATCH 8/8] pandas-dev issue #30699 --- pandas/tests/arrays/test_datetimelike.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/arrays/test_datetimelike.py b/pandas/tests/arrays/test_datetimelike.py index a0b270224d30a..81bcff410a4d3 100644 --- a/pandas/tests/arrays/test_datetimelike.py +++ b/pandas/tests/arrays/test_datetimelike.py @@ -91,7 +91,7 @@ def test_compare_len1_raises(self): pd.date_range("2020", periods=3), pd.date_range("2020", periods=3, tz="UTC"), pd.timedelta_range("0 days", periods=3), - pd.period_range("2020Q1", periods=3, freq="Q") + pd.period_range("2020Q1", periods=3, freq="Q"), ], ) def test_compare_with_Categorical(self, result):