Skip to content

TST: skip fewer tests #44918

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 3 commits into from
Dec 16, 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
2 changes: 1 addition & 1 deletion ci/deps/actions-38-db.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies:
- pytest-cov>=2.10.1 # this is only needed in the coverage build, ref: GH 35737

# pandas dependencies
- aiobotocore<2.0.0
- aiobotocore<2.0.0 # GH#44311 pinned to fix docbuild
- beautifulsoup4
- boto3
- botocore>=1.11
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ dependencies:

- pytables>=3.6.1 # pandas.read_hdf, DataFrame.to_hdf
- s3fs>=0.4.0 # file IO when using 's3://...' path
- aiobotocore<2.0.0
- aiobotocore<2.0.0 # GH#44311 pinned to fix docbuild
- fsspec>=0.7.4 # for generic remote file operations
- gcsfs>=0.6.0 # file IO when using 'gcs://...' path
- sqlalchemy # pandas.read_sql, DataFrame.to_sql
Expand Down
15 changes: 15 additions & 0 deletions pandas/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,21 @@ def index_flat(request):
index_flat2 = index_flat


@pytest.fixture(
params=[
key
for key in indices_dict
if not isinstance(indices_dict[key], MultiIndex) and indices_dict[key].is_unique
]
)
def index_flat_unique(request):
"""
index_flat with uniqueness requirement.
"""
key = request.param
return indices_dict[key].copy()


@pytest.fixture(
params=[
key
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/arrays/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -2377,7 +2377,7 @@ def describe(self):

return result

def isin(self, values) -> np.ndarray:
def isin(self, values) -> npt.NDArray[np.bool_]:
"""
Check whether `values` are contained in Categorical.

Expand All @@ -2394,7 +2394,7 @@ def isin(self, values) -> np.ndarray:

Returns
-------
isin : numpy.ndarray (bool dtype)
np.ndarray[bool]

Raises
------
Expand Down
20 changes: 10 additions & 10 deletions pandas/tests/base/test_fillna.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@
import numpy as np
import pytest

from pandas.core.dtypes.generic import ABCMultiIndex

from pandas import Index
from pandas import MultiIndex
import pandas._testing as tm
from pandas.tests.base.common import allow_na_ops


def test_fillna(index_or_series_obj):
# GH 11343
obj = index_or_series_obj
if isinstance(obj, ABCMultiIndex):
pytest.skip("MultiIndex doesn't support isna")

if isinstance(obj, MultiIndex):
msg = "isna is not defined for MultiIndex"
with pytest.raises(NotImplementedError, match=msg):
obj.fillna(0)
return

# values will not be changed
fill_value = obj.values[0] if len(obj) > 0 else 0
result = obj.fillna(fill_value)
if isinstance(obj, Index):
tm.assert_index_equal(obj, result)
else:
tm.assert_series_equal(obj, result)

tm.assert_equal(obj, result)

# check shallow_copied
assert obj is not result
Expand All @@ -41,7 +41,7 @@ def test_fillna_null(null_obj, index_or_series_obj):
pytest.skip(f"{klass} doesn't allow for NA operations")
elif len(obj) < 1:
pytest.skip("Test doesn't make sense on empty data")
elif isinstance(obj, ABCMultiIndex):
elif isinstance(obj, MultiIndex):
pytest.skip(f"MultiIndex can't hold '{null_obj}'")

values = obj._values
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/base/test_unique.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,6 @@ def test_unique_bad_unicode(index_or_series):
@pytest.mark.parametrize("dropna", [True, False])
def test_nunique_dropna(dropna):
# GH37566
s = pd.Series(["yes", "yes", pd.NA, np.nan, None, pd.NaT])
res = s.nunique(dropna)
ser = pd.Series(["yes", "yes", pd.NA, np.nan, None, pd.NaT])
res = ser.nunique(dropna)
assert res == 1 if dropna else 5
15 changes: 3 additions & 12 deletions pandas/tests/extension/base/dim2.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,7 @@ def test_fillna_2d_method(self, data_missing, method):
self.assert_extension_array_equal(result, expected)

@pytest.mark.parametrize("method", ["mean", "median", "var", "std", "sum", "prod"])
def test_reductions_2d_axis_none(self, data, method, request):
if not hasattr(data, method):
pytest.skip("test is not applicable for this type/dtype")

def test_reductions_2d_axis_none(self, data, method):
arr2d = data.reshape(1, -1)

err_expected = None
Expand All @@ -178,10 +175,7 @@ def test_reductions_2d_axis_none(self, data, method, request):
assert is_matching_na(result, expected) or result == expected

@pytest.mark.parametrize("method", ["mean", "median", "var", "std", "sum", "prod"])
def test_reductions_2d_axis0(self, data, method, request):
if not hasattr(data, method):
pytest.skip("test is not applicable for this type/dtype")

def test_reductions_2d_axis0(self, data, method):
arr2d = data.reshape(1, -1)

kwargs = {}
Expand Down Expand Up @@ -231,10 +225,7 @@ def get_reduction_result_dtype(dtype):
# punt on method == "var"

@pytest.mark.parametrize("method", ["mean", "median", "var", "std", "sum", "prod"])
def test_reductions_2d_axis1(self, data, method, request):
if not hasattr(data, method):
pytest.skip("test is not applicable for this type/dtype")

def test_reductions_2d_axis1(self, data, method):
arr2d = data.reshape(1, -1)

try:
Expand Down
8 changes: 6 additions & 2 deletions pandas/tests/indexes/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,17 @@ def test_unique(self, index_flat):
result = i.unique()
tm.assert_index_equal(result, expected)

def test_searchsorted_monotonic(self, index_flat):
def test_searchsorted_monotonic(self, index_flat, request):
# GH17271
index = index_flat
# not implemented for tuple searches in MultiIndex
# or Intervals searches in IntervalIndex
if isinstance(index, pd.IntervalIndex):
pytest.skip("Skip check for MultiIndex/IntervalIndex")
mark = pytest.mark.xfail(
reason="IntervalIndex.searchsorted does not support Interval arg",
raises=NotImplementedError,
)
request.node.add_marker(mark)

# nothing to test if the index is empty
if index.empty:
Expand Down
24 changes: 8 additions & 16 deletions pandas/tests/indexes/test_setops.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,11 @@ def test_symmetric_difference(self, index):
(None, None, None),
],
)
def test_corner_union(self, index_flat, fname, sname, expected_name):
def test_corner_union(self, index_flat_unique, fname, sname, expected_name):
# GH#9943, GH#9862
# Test unions with various name combinations
# Do not test MultiIndex or repeats
index = index_flat
if not index.is_unique:
pytest.skip("Not for MultiIndex or repeated indices")
index = index_flat_unique

# Test copy.union(copy)
first = index.copy().set_names(fname)
Expand Down Expand Up @@ -318,10 +316,8 @@ def test_corner_union(self, index_flat, fname, sname, expected_name):
(None, None, None),
],
)
def test_union_unequal(self, index_flat, fname, sname, expected_name):
index = index_flat
if not index.is_unique:
pytest.skip("Not for MultiIndex or repeated indices")
def test_union_unequal(self, index_flat_unique, fname, sname, expected_name):
index = index_flat_unique

# test copy.union(subset) - need sort for unicode and string
first = index.copy().set_names(fname)
Expand All @@ -340,12 +336,10 @@ def test_union_unequal(self, index_flat, fname, sname, expected_name):
(None, None, None),
],
)
def test_corner_intersect(self, index_flat, fname, sname, expected_name):
def test_corner_intersect(self, index_flat_unique, fname, sname, expected_name):
# GH#35847
# Test intersections with various name combinations
index = index_flat
if not index.is_unique:
pytest.skip("Not for MultiIndex or repeated indices")
index = index_flat_unique

# Test copy.intersection(copy)
first = index.copy().set_names(fname)
Expand Down Expand Up @@ -385,10 +379,8 @@ def test_corner_intersect(self, index_flat, fname, sname, expected_name):
(None, None, None),
],
)
def test_intersect_unequal(self, index_flat, fname, sname, expected_name):
index = index_flat
if not index.is_unique:
pytest.skip("Not for MultiIndex or repeated indices")
def test_intersect_unequal(self, index_flat_unique, fname, sname, expected_name):
index = index_flat_unique

# test copy.intersection(subset) - need sort for unicode and string
first = index.copy().set_names(fname)
Expand Down
12 changes: 8 additions & 4 deletions pandas/tests/io/excel/test_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,18 @@ def test_read_excel_multiindex_empty_level(self, ext):
@pytest.mark.parametrize("c_idx_levels", [1, 3])
@pytest.mark.parametrize("r_idx_levels", [1, 3])
def test_excel_multindex_roundtrip(
self, ext, c_idx_names, r_idx_names, c_idx_levels, r_idx_levels
self, ext, c_idx_names, r_idx_names, c_idx_levels, r_idx_levels, request
):
# see gh-4679
with tm.ensure_clean(ext) as pth:
if c_idx_levels == 1 and c_idx_names:
pytest.skip(
"Column index name cannot be serialized unless it's a MultiIndex"
if (c_idx_levels == 1 and c_idx_names) and not (
r_idx_levels == 3 and not r_idx_names
):
mark = pytest.mark.xfail(
reason="Column index name cannot be serialized unless "
"it's a MultiIndex"
)
request.node.add_marker(mark)

# Empty name case current read in as
# unnamed levels, not Nones.
Expand Down
3 changes: 0 additions & 3 deletions pandas/tests/io/formats/test_to_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,6 @@ def test_to_csv_compression(self, compression_only, read_infer, to_infer):
# see gh-15008
compression = compression_only

if compression == "zip":
pytest.skip(f"{compression} is not supported for to_csv")

# We'll complete file extension subsequently.
filename = "test."

Expand Down
3 changes: 0 additions & 3 deletions pandas/tests/io/json/test_compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ def test_to_json_compression(compression_only, read_infer, to_infer):
# see gh-15008
compression = compression_only

if compression == "zip":
pytest.skip(f"{compression} is not supported for to_csv")

# We'll complete file extension subsequently.
filename = "test."

Expand Down
3 changes: 1 addition & 2 deletions pandas/tests/io/json/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -1323,10 +1323,9 @@ def test_to_jsonl(self):
tm.assert_frame_equal(read_json(result, lines=True), df)

# TODO: there is a near-identical test for pytables; can we share?
@pytest.mark.xfail(reason="GH#13774 encoding kwarg not supported", raises=TypeError)
def test_latin_encoding(self):
# GH 13774
pytest.skip("encoding not implemented in .to_json(), xref #13774")

values = [
[b"E\xc9, 17", b"", b"a", b"b", b"c"],
[b"E\xc9, 17", b"a", b"b", b"c"],
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/series/methods/test_rank.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ class TestSeriesRank:
"dense": np.array([1, 3, 4, 2, np.nan, 2, 1, 5, np.nan, 3]),
}

@td.skip_if_no_scipy
def test_rank(self, datetime_series):
pytest.importorskip("scipy.stats.special")
rankdata = pytest.importorskip("scipy.stats.rankdata")
from scipy.stats import rankdata

datetime_series[::2] = np.nan
datetime_series[:10][::3] = 4.0
Expand Down Expand Up @@ -280,9 +280,9 @@ def test_rank_desc_mix_nans_infs(self):
exp = Series([3, np.nan, 1, 4, 2], dtype="float64")
tm.assert_series_equal(result, exp)

@td.skip_if_no_scipy
def test_rank_methods_series(self):
pytest.importorskip("scipy.stats.special")
rankdata = pytest.importorskip("scipy.stats.rankdata")
from scipy.stats import rankdata

xs = np.random.randn(9)
xs = np.concatenate([xs[i:] for i in range(0, 9, 2)]) # add duplicates
Expand Down
6 changes: 5 additions & 1 deletion pandas/tests/test_algos.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,8 @@ def test_on_index_object(self):
def test_dtype_preservation(self, any_numpy_dtype):
# GH 15442
if any_numpy_dtype in (tm.BYTES_DTYPES + tm.STRING_DTYPES):
pytest.skip("skip string dtype")
data = [1, 2, 2]
uniques = [1, 2]
elif is_integer_dtype(any_numpy_dtype):
data = [1, 2, 2]
uniques = [1, 2]
Expand All @@ -533,6 +534,9 @@ def test_dtype_preservation(self, any_numpy_dtype):
result = Series(data, dtype=any_numpy_dtype).unique()
expected = np.array(uniques, dtype=any_numpy_dtype)

if any_numpy_dtype in tm.STRING_DTYPES:
expected = expected.astype(object)

tm.assert_numpy_array_equal(result, expected)

def test_datetime64_dtype_array_returned(self):
Expand Down