Skip to content

TST: avoid re-running tests 14 times #43922

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 1 commit into from
Oct 8, 2021
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
32 changes: 0 additions & 32 deletions pandas/tests/indexes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,38 +525,6 @@ def test_format_empty(self):
assert empty_idx.format() == []
assert empty_idx.format(name=True) == [""]

def test_hasnans_isnans(self, index_flat):
# GH 11343, added tests for hasnans / isnans
index = index_flat

# cases in indices doesn't include NaN
idx = index.copy(deep=True)
expected = np.array([False] * len(idx), dtype=bool)
tm.assert_numpy_array_equal(idx._isnan, expected)
assert idx.hasnans is False

idx = index.copy(deep=True)
values = np.asarray(idx.values)

if len(index) == 0:
return
elif isinstance(index, NumericIndex) and is_integer_dtype(index.dtype):
return
elif isinstance(index, DatetimeIndexOpsMixin):
values[1] = iNaT
else:
values[1] = np.nan

if isinstance(index, PeriodIndex):
idx = type(index)(values, freq=index.freq)
else:
idx = type(index)(values)

expected = np.array([False] * len(idx), dtype=bool)
expected[1] = True
tm.assert_numpy_array_equal(idx._isnan, expected)
assert idx.hasnans is True

def test_fillna(self, index):
# GH 11343
if len(index) == 0:
Expand Down
33 changes: 33 additions & 0 deletions pandas/tests/indexes/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from pandas.compat import IS64

from pandas.core.dtypes.common import (
is_integer_dtype,
is_period_dtype,
needs_i8_conversion,
)
Expand Down Expand Up @@ -366,6 +367,38 @@ def test_asi8_deprecation(self, index):
with tm.assert_produces_warning(warn):
index.asi8

def test_hasnans_isnans(self, index_flat):
# GH#11343, added tests for hasnans / isnans
index = index_flat

# cases in indices doesn't include NaN
idx = index.copy(deep=True)
expected = np.array([False] * len(idx), dtype=bool)
tm.assert_numpy_array_equal(idx._isnan, expected)
assert idx.hasnans is False

idx = index.copy(deep=True)
values = np.asarray(idx.values)

if len(index) == 0:
return
elif isinstance(index, NumericIndex) and is_integer_dtype(index.dtype):
return
elif needs_i8_conversion(index.dtype):
values[1] = iNaT
else:
values[1] = np.nan

if isinstance(index, PeriodIndex):
idx = type(index)(values, freq=index.freq)
else:
idx = type(index)(values)

expected = np.array([False] * len(idx), dtype=bool)
expected[1] = True
tm.assert_numpy_array_equal(idx._isnan, expected)
assert idx.hasnans is True


@pytest.mark.parametrize("na_position", [None, "middle"])
def test_sort_values_invalid_na_position(index_with_missing, na_position):
Expand Down