Skip to content

Added pd.NA to nulls_fixture #31799

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 6 commits into from
Feb 20, 2020
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
2 changes: 1 addition & 1 deletion pandas/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ def other_closed(request):
return request.param


@pytest.fixture(params=[None, np.nan, pd.NaT, float("nan"), np.float("NaN")])
@pytest.fixture(params=[None, np.nan, pd.NaT, float("nan"), np.float("NaN"), pd.NA])
def nulls_fixture(request):
"""
Fixture for each null type in pandas.
Expand Down
8 changes: 8 additions & 0 deletions pandas/tests/arithmetic/test_interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ def test_compare_scalar_interval_mixed_closed(self, op, closed, other_closed):
def test_compare_scalar_na(self, op, array, nulls_fixture):
result = op(array, nulls_fixture)
expected = self.elementwise_comparison(op, array, nulls_fixture)

if nulls_fixture is pd.NA:
pytest.xfail("assert_numpy_array_equal broken for pd.NA")
Copy link
Contributor

Choose a reason for hiding this comment

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

can you make an issue for this (and ref here)


tm.assert_numpy_array_equal(result, expected)

@pytest.mark.parametrize(
Expand Down Expand Up @@ -207,6 +211,10 @@ def test_compare_list_like_nan(self, op, array, nulls_fixture):
other = [nulls_fixture] * 4
result = op(array, other)
expected = self.elementwise_comparison(op, array, other)

if nulls_fixture is pd.NA:
pytest.xfail("assert_numpy_array_equal broken for pd.NA")

tm.assert_numpy_array_equal(result, expected)

@pytest.mark.parametrize(
Expand Down
4 changes: 4 additions & 0 deletions pandas/tests/indexes/multi/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,10 @@ def test_get_loc_nan(level, nulls_fixture):
key = ["b", "d"]
levels[level] = np.array([0, nulls_fixture], dtype=type(nulls_fixture))
key[level] = nulls_fixture

if nulls_fixture is pd.NA:
pytest.xfail("MultiIndex from pd.NA broken")

idx = MultiIndex.from_product(levels)
assert idx.get_loc(tuple(key)) == 3

Expand Down
6 changes: 6 additions & 0 deletions pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ def test_index_ctor_infer_nat_dt_like(self, pos, klass, dtype, ctor, nulls_fixtu
data = [ctor]
data.insert(pos, nulls_fixture)

if nulls_fixture is pd.NA:
pytest.xfail("Broken with pd.NA?")

result = Index(data)
tm.assert_index_equal(result, expected)

Expand Down Expand Up @@ -1964,6 +1967,9 @@ def test_isin_nan_common_float64(self, nulls_fixture):
pytest.skip("pd.NaT not compatible with Float64Index")

# Float64Index overrides isin, so must be checked separately
if nulls_fixture is pd.NA:
pytest.xfail("Not sure how to handle with Float64Index?")
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure about this test. Maybe logical to support, though we also skip for pd.NaT atm

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should support converting pd.NA into np.nan in creating a float index, since pd.NA and np.nan behave differently


tm.assert_numpy_array_equal(
Float64Index([1.0, nulls_fixture]).isin([np.nan]), np.array([False, True])
)
Expand Down