Skip to content

TST: fix flaky xfail #28016

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 2 commits into from
Aug 19, 2019
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
19 changes: 9 additions & 10 deletions pandas/tests/series/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1482,23 +1482,18 @@ 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))

# 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
Copy link
Contributor

Choose a reason for hiding this comment

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

Huh, I can't say that I understand why this would be.

Copy link
Member Author

Choose a reason for hiding this comment

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

in _recode_for_categories we're going through an ensure_object path and problems crop up around then. I'm not sure exactly why, but I think the solution will involve casting from datetime64[D] to datetime64[ns] without going through object

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)
Expand All @@ -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, tc2 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)
Expand Down