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 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
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 and array.dtype != pd.IntervalDtype("int"):
pytest.xfail("broken for non-integer IntervalArray; see GH 31882")

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("broken for non-integer IntervalArray; see GH 31882")

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 in np.array broken; see GH 31883")

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

Expand Down
7 changes: 7 additions & 0 deletions pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,10 @@ 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:
expected = Index([pd.NA, pd.NaT])
pytest.xfail("Broken with np.NaT ctor; see GH 31884")

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

Expand Down Expand Up @@ -1964,6 +1968,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("Float64Index cannot contain pd.NA")

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