Skip to content

Commit e7d1964

Browse files
TST (string dtype): clean-up assorted xfails (#60345)
1 parent 720a6e7 commit e7d1964

File tree

7 files changed

+10
-34
lines changed

7 files changed

+10
-34
lines changed

pandas/tests/base/test_conversion.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import numpy as np
22
import pytest
33

4-
from pandas._config import using_string_dtype
5-
64
from pandas.compat import HAS_PYARROW
75
from pandas.compat.numpy import np_version_gt2
86

@@ -392,9 +390,6 @@ def test_to_numpy(arr, expected, zero_copy, index_or_series_or_array):
392390
assert np.may_share_memory(result_nocopy1, result_nocopy2)
393391

394392

395-
@pytest.mark.xfail(
396-
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)", strict=False
397-
)
398393
@pytest.mark.parametrize("as_series", [True, False])
399394
@pytest.mark.parametrize(
400395
"arr", [np.array([1, 2, 3], dtype="int64"), np.array(["a", "b", "c"], dtype=object)]
@@ -406,13 +401,13 @@ def test_to_numpy_copy(arr, as_series, using_infer_string):
406401

407402
# no copy by default
408403
result = obj.to_numpy()
409-
if using_infer_string and arr.dtype == object:
404+
if using_infer_string and arr.dtype == object and obj.dtype.storage == "pyarrow":
410405
assert np.shares_memory(arr, result) is False
411406
else:
412407
assert np.shares_memory(arr, result) is True
413408

414409
result = obj.to_numpy(copy=False)
415-
if using_infer_string and arr.dtype == object:
410+
if using_infer_string and arr.dtype == object and obj.dtype.storage == "pyarrow":
416411
assert np.shares_memory(arr, result) is False
417412
else:
418413
assert np.shares_memory(arr, result) is True

pandas/tests/indexes/multi/test_setops.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import numpy as np
22
import pytest
33

4-
from pandas._config import using_string_dtype
5-
64
import pandas as pd
75
from pandas import (
86
CategoricalIndex,
@@ -754,13 +752,12 @@ def test_intersection_keep_ea_dtypes(val, any_numeric_ea_dtype):
754752
tm.assert_index_equal(result, expected)
755753

756754

757-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
758755
def test_union_with_na_when_constructing_dataframe():
759756
# GH43222
760757
series1 = Series(
761758
(1,),
762759
index=MultiIndex.from_arrays(
763-
[Series([None], dtype="string"), Series([None], dtype="string")]
760+
[Series([None], dtype="str"), Series([None], dtype="str")]
764761
),
765762
)
766763
series2 = Series((10, 20), index=MultiIndex.from_tuples(((None, None), ("a", "b"))))

pandas/tests/indexes/test_base.py

+1-11
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@
88
import numpy as np
99
import pytest
1010

11-
from pandas._config import using_string_dtype
12-
13-
from pandas.compat import (
14-
HAS_PYARROW,
15-
IS64,
16-
)
11+
from pandas.compat import IS64
1712
from pandas.errors import InvalidIndexError
1813
import pandas.util._test_decorators as td
1914

@@ -823,11 +818,6 @@ def test_isin(self, values, index, expected):
823818
expected = np.array(expected, dtype=bool)
824819
tm.assert_numpy_array_equal(result, expected)
825820

826-
@pytest.mark.xfail(
827-
using_string_dtype() and not HAS_PYARROW,
828-
reason="TODO(infer_string)",
829-
strict=False,
830-
)
831821
def test_isin_nan_common_object(
832822
self, nulls_fixture, nulls_fixture2, using_infer_string
833823
):

pandas/tests/io/excel/test_readers.py

-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import numpy as np
1818
import pytest
1919

20-
from pandas._config import using_string_dtype
21-
2220
import pandas.util._test_decorators as td
2321

2422
import pandas as pd
@@ -625,7 +623,6 @@ def test_reader_dtype_str(self, read_ext, dtype, expected):
625623
expected = DataFrame(expected)
626624
tm.assert_frame_equal(actual, expected)
627625

628-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
629626
def test_dtype_backend(self, read_ext, dtype_backend, engine, tmp_excel):
630627
# GH#36712
631628
if read_ext in (".xlsb", ".xls"):

pandas/tests/io/excel/test_writers.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
import numpy as np
1414
import pytest
1515

16-
from pandas._config import using_string_dtype
17-
1816
from pandas.compat._optional import import_optional_dependency
1917
import pandas.util._test_decorators as td
2018

@@ -1387,12 +1385,11 @@ def test_freeze_panes(self, tmp_excel):
13871385
result = pd.read_excel(tmp_excel, index_col=0)
13881386
tm.assert_frame_equal(result, expected)
13891387

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

pandas/tests/io/test_stata.py

-1
Original file line numberDiff line numberDiff line change
@@ -1719,7 +1719,6 @@ def test_date_parsing_ignores_format_details(self, column, datapath):
17191719
formatted = df.loc[0, column + "_fmt"]
17201720
assert unformatted == formatted
17211721

1722-
# @pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
17231722
@pytest.mark.parametrize("byteorder", ["little", "big"])
17241723
def test_writer_117(self, byteorder, temp_file, using_infer_string):
17251724
original = DataFrame(

pandas/tests/reshape/test_union_categoricals.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import numpy as np
22
import pytest
33

4-
from pandas._config import using_string_dtype
5-
64
from pandas.core.dtypes.concat import union_categoricals
75

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

127-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
128125
@pytest.mark.parametrize("val", [[], ["1"]])
129126
def test_union_categoricals_empty(self, val, request, using_infer_string):
130127
# GH 13759
131128
if using_infer_string and val == ["1"]:
132-
request.applymarker(pytest.mark.xfail("object and strings dont match"))
129+
request.applymarker(
130+
pytest.mark.xfail(
131+
reason="TDOD(infer_string) object and strings dont match"
132+
)
133+
)
133134
res = union_categoricals([Categorical([]), Categorical(val)])
134135
exp = Categorical(val)
135136
tm.assert_categorical_equal(res, exp)

0 commit comments

Comments
 (0)