From a202aec480d9bb6ea2c420fab8b7989509c95f7b Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Mon, 19 Aug 2019 10:11:52 -0700 Subject: [PATCH 1/2] TST: fix flaky xfail --- pandas/tests/series/test_analytics.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/pandas/tests/series/test_analytics.py b/pandas/tests/series/test_analytics.py index 3a5a387b919be..0175590291220 100644 --- a/pandas/tests/series/test_analytics.py +++ b/pandas/tests/series/test_analytics.py @@ -1482,16 +1482,7 @@ def test_value_counts_with_nan(self): @pytest.mark.parametrize( "dtype", - [ - "int_", - "uint", - "float_", - "unicode_", - "timedelta64[h]", - pytest.param( - "datetime64[D]", marks=pytest.mark.xfail(reason="GH#7996", strict=True) - ), - ], + ["int_", "uint", "float_", "unicode_", "timedelta64[h]", "datetime64[D]"], ) def test_drop_duplicates_categorical_non_bool(self, dtype, ordered_fixture): cat_array = np.array([1, 2, 3, 4, 5], dtype=np.dtype(dtype)) @@ -1499,6 +1490,10 @@ def test_drop_duplicates_categorical_non_bool(self, dtype, ordered_fixture): # Test case 1 input1 = np.array([1, 2, 3, 3], dtype=np.dtype(dtype)) tc1 = Series(Categorical(input1, categories=cat_array, ordered=ordered_fixture)) + if dtype == "datetime64[D]": + # pre-empty flaky xfail, tc1 values are seemingly-random + if not (np.array(tc1) == input1).all(): + pytest.xfail(reason="GH#7996") expected = Series([False, False, False, True]) tm.assert_series_equal(tc1.duplicated(), expected) @@ -1524,6 +1519,10 @@ def test_drop_duplicates_categorical_non_bool(self, dtype, ordered_fixture): # Test case 2 input2 = np.array([1, 2, 3, 5, 3, 2, 4], dtype=np.dtype(dtype)) tc2 = Series(Categorical(input2, categories=cat_array, ordered=ordered_fixture)) + if dtype == "datetime64[D]": + # pre-empty flaky xfail, tc1 values are seemingly-random + if not (np.array(tc2) == input2).all(): + pytest.xfail(reason="GH#7996") expected = Series([False, False, False, False, True, True, False]) tm.assert_series_equal(tc2.duplicated(), expected) From 88f4340d052f7e8815441a3f53999aca4a019b30 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Mon, 19 Aug 2019 10:12:46 -0700 Subject: [PATCH 2/2] Fix comment --- pandas/tests/series/test_analytics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/series/test_analytics.py b/pandas/tests/series/test_analytics.py index 0175590291220..1ddaa4692d741 100644 --- a/pandas/tests/series/test_analytics.py +++ b/pandas/tests/series/test_analytics.py @@ -1520,7 +1520,7 @@ def test_drop_duplicates_categorical_non_bool(self, dtype, ordered_fixture): input2 = np.array([1, 2, 3, 5, 3, 2, 4], dtype=np.dtype(dtype)) tc2 = Series(Categorical(input2, categories=cat_array, ordered=ordered_fixture)) if dtype == "datetime64[D]": - # pre-empty flaky xfail, tc1 values are seemingly-random + # pre-empty flaky xfail, tc2 values are seemingly-random if not (np.array(tc2) == input2).all(): pytest.xfail(reason="GH#7996")