Skip to content

Commit 7bd594c

Browse files
TST (string dtype): add explicit object vs str dtype to index fixture (#60116)
1 parent 2ead198 commit 7bd594c

File tree

5 files changed

+12
-4
lines changed

5 files changed

+12
-4
lines changed

pandas/conftest.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,8 @@ def _create_mi_with_dt64tz_level():
667667

668668

669669
indices_dict = {
670-
"string": Index([f"pandas_{i}" for i in range(10)]),
670+
"object": Index([f"pandas_{i}" for i in range(10)], dtype=object),
671+
"string": Index([f"pandas_{i}" for i in range(10)], dtype="str"),
671672
"datetime": date_range("2020-01-01", periods=10),
672673
"datetime-tz": date_range("2020-01-01", periods=10, tz="US/Pacific"),
673674
"period": period_range("2020-01-01", periods=10, freq="D"),

pandas/tests/indexes/test_any_index.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def test_map_identity_mapping(index, request):
4040
# GH#12766
4141

4242
result = index.map(lambda x: x)
43-
if index.dtype == object and result.dtype == bool:
43+
if index.dtype == object and (result.dtype == bool or result.dtype == "string"):
4444
assert (index == result).all()
4545
# TODO: could work that into the 'exact="equiv"'?
4646
return # FIXME: doesn't belong in this file anymore!

pandas/tests/indexes/test_old_base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def test_ensure_copied_data(self, index):
256256
"RangeIndex cannot be initialized from data, "
257257
"MultiIndex and CategoricalIndex are tested separately"
258258
)
259-
elif index.dtype == object and index.inferred_type == "boolean":
259+
elif index.dtype == object and index.inferred_type in ["boolean", "string"]:
260260
init_kwargs["dtype"] = index.dtype
261261

262262
index_type = type(index)

pandas/tests/indexes/test_setops.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,13 @@ def test_difference_base(self, sort, index):
299299
first.difference([1, 2, 3], sort)
300300

301301
@pytest.mark.filterwarnings(r"ignore:PeriodDtype\[B\] is deprecated:FutureWarning")
302-
def test_symmetric_difference(self, index):
302+
def test_symmetric_difference(self, index, using_infer_string, request):
303+
if (
304+
using_infer_string
305+
and index.dtype == "object"
306+
and index.inferred_type == "string"
307+
):
308+
request.applymarker(pytest.mark.xfail(reason="TODO: infer_string"))
303309
if isinstance(index, CategoricalIndex):
304310
pytest.skip(f"Not relevant for {type(index).__name__}")
305311
if len(index) < 2:

pandas/tests/test_algos.py

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def test_factorize_complex(self):
6565
expected_uniques = np.array([(1 + 0j), (2 + 0j), (2 + 1j)], dtype=complex)
6666
tm.assert_numpy_array_equal(uniques, expected_uniques)
6767

68+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
6869
def test_factorize(self, index_or_series_obj, sort):
6970
obj = index_or_series_obj
7071
result_codes, result_uniques = obj.factorize(sort=sort)

0 commit comments

Comments
 (0)