Skip to content
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

[backport 2.3.x] TST (string dtype): clean-up assorted xfails (#60345) #60349

Merged
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
9 changes: 2 additions & 7 deletions pandas/tests/base/test_conversion.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import numpy as np
import pytest

from pandas._config import using_string_dtype

from pandas.compat import HAS_PYARROW
from pandas.compat.numpy import np_version_gt2

Expand Down Expand Up @@ -391,9 +389,6 @@ def test_to_numpy(arr, expected, zero_copy, index_or_series_or_array):
assert np.may_share_memory(result_nocopy1, result_nocopy2)


@pytest.mark.xfail(
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)", strict=False
)
@pytest.mark.parametrize("as_series", [True, False])
@pytest.mark.parametrize(
"arr", [np.array([1, 2, 3], dtype="int64"), np.array(["a", "b", "c"], dtype=object)]
Expand All @@ -405,13 +400,13 @@ def test_to_numpy_copy(arr, as_series, using_infer_string):

# no copy by default
result = obj.to_numpy()
if using_infer_string and arr.dtype == object:
if using_infer_string and arr.dtype == object and obj.dtype.storage == "pyarrow":
assert np.shares_memory(arr, result) is False
else:
assert np.shares_memory(arr, result) is True

result = obj.to_numpy(copy=False)
if using_infer_string and arr.dtype == object:
if using_infer_string and arr.dtype == object and obj.dtype.storage == "pyarrow":
assert np.shares_memory(arr, result) is False
else:
assert np.shares_memory(arr, result) is True
Expand Down
5 changes: 1 addition & 4 deletions pandas/tests/indexes/multi/test_setops.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import numpy as np
import pytest

from pandas._config import using_string_dtype

import pandas as pd
from pandas import (
CategoricalIndex,
Expand Down Expand Up @@ -760,13 +758,12 @@ def test_intersection_keep_ea_dtypes(val, any_numeric_ea_dtype):
tm.assert_index_equal(result, expected)


@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
def test_union_with_na_when_constructing_dataframe():
# GH43222
series1 = Series(
(1,),
index=MultiIndex.from_arrays(
[Series([None], dtype="string"), Series([None], dtype="string")]
[Series([None], dtype="str"), Series([None], dtype="str")]
),
)
series2 = Series((10, 20), index=MultiIndex.from_tuples(((None, None), ("a", "b"))))
Expand Down
12 changes: 1 addition & 11 deletions pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@
import numpy as np
import pytest

from pandas._config import using_string_dtype

from pandas.compat import (
HAS_PYARROW,
IS64,
)
from pandas.compat import IS64
from pandas.errors import InvalidIndexError
import pandas.util._test_decorators as td

Expand Down Expand Up @@ -862,11 +857,6 @@ def test_isin(self, values, index, expected):
result = index.isin(values)
tm.assert_numpy_array_equal(result, expected)

@pytest.mark.xfail(
using_string_dtype() and not HAS_PYARROW,
reason="TODO(infer_string)",
strict=False,
)
def test_isin_nan_common_object(
self, nulls_fixture, nulls_fixture2, using_infer_string
):
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/io/excel/test_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,6 @@ def test_reader_dtype_str(self, read_ext, dtype, expected):
actual = pd.read_excel(basename + read_ext, dtype=dtype)
tm.assert_frame_equal(actual, expected)

@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
def test_dtype_backend(self, read_ext, dtype_backend, engine):
# GH#36712
if read_ext in (".xlsb", ".xls"):
Expand Down
5 changes: 1 addition & 4 deletions pandas/tests/io/excel/test_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import numpy as np
import pytest

from pandas._config import using_string_dtype

from pandas.compat import is_platform_windows
from pandas.compat._constants import PY310
from pandas.compat._optional import import_optional_dependency
Expand Down Expand Up @@ -1316,12 +1314,11 @@ def test_freeze_panes(self, path):
result = pd.read_excel(path, index_col=0)
tm.assert_frame_equal(result, expected)

@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
def test_path_path_lib(self, engine, ext):
df = DataFrame(
1.1 * np.arange(120).reshape((30, 4)),
columns=Index(list("ABCD")),
index=Index([f"i-{i}" for i in range(30)], dtype=object),
index=Index([f"i-{i}" for i in range(30)]),
)
writer = partial(df.to_excel, engine=engine)

Expand Down
9 changes: 5 additions & 4 deletions pandas/tests/reshape/test_union_categoricals.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import numpy as np
import pytest

from pandas._config import using_string_dtype

from pandas.core.dtypes.concat import union_categoricals

import pandas as pd
Expand Down Expand Up @@ -124,12 +122,15 @@ def test_union_categoricals_nan(self):
exp = Categorical([np.nan, np.nan, np.nan, np.nan])
tm.assert_categorical_equal(res, exp)

@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
@pytest.mark.parametrize("val", [[], ["1"]])
def test_union_categoricals_empty(self, val, request, using_infer_string):
# GH 13759
if using_infer_string and val == ["1"]:
request.applymarker(pytest.mark.xfail("object and strings dont match"))
request.applymarker(
pytest.mark.xfail(
reason="TDOD(infer_string) object and strings dont match"
)
)
res = union_categoricals([Categorical([]), Categorical(val)])
exp = Categorical(val)
tm.assert_categorical_equal(res, exp)
Expand Down
Loading