Skip to content

Commit dbeeb1f

Browse files
TST (string dtype): un-xfail string tests specific to object dtype (pandas-dev#59433)
Co-authored-by: Joris Van den Bossche <[email protected]>
1 parent 988a7c8 commit dbeeb1f

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

pandas/tests/copy_view/test_interp_fillna.py

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

4-
from pandas._config import using_string_dtype
5-
6-
from pandas.compat import HAS_PYARROW
7-
84
from pandas import (
95
NA,
106
DataFrame,
@@ -114,18 +110,18 @@ def test_interp_fill_functions_inplace(func, dtype):
114110
assert view._mgr._has_no_reference(0)
115111

116112

117-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
118113
def test_interpolate_cannot_with_object_dtype():
119114
df = DataFrame({"a": ["a", np.nan, "c"], "b": 1})
115+
df["a"] = df["a"].astype(object)
120116

121117
msg = "DataFrame cannot interpolate with object dtype"
122118
with pytest.raises(TypeError, match=msg):
123119
df.interpolate()
124120

125121

126-
@pytest.mark.xfail(using_string_dtype() and HAS_PYARROW, reason="TODO(infer_string)")
127122
def test_interpolate_object_convert_no_op():
128123
df = DataFrame({"a": ["a", "b", "c"], "b": 1})
124+
df["a"] = df["a"].astype(object)
129125
arr_a = get_array(df, "a")
130126

131127
# Now CoW makes a copy, it should not!

pandas/tests/copy_view/test_replace.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,9 @@ def test_replace_empty_list():
259259
assert not df2._mgr._has_no_reference(0)
260260

261261

262-
@pytest.mark.xfail(using_string_dtype() and HAS_PYARROW, reason="TODO(infer_string)")
263262
@pytest.mark.parametrize("value", ["d", None])
264263
def test_replace_object_list_inplace(value):
265-
df = DataFrame({"a": ["a", "b", "c"]})
264+
df = DataFrame({"a": ["a", "b", "c"]}, dtype=object)
266265
arr = get_array(df, "a")
267266
df.replace(["c"], value, inplace=True)
268267
assert np.shares_memory(arr, get_array(df, "a"))

pandas/tests/test_algos.py

+18-10
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import numpy as np
55
import pytest
66

7-
from pandas._config import using_string_dtype
8-
97
from pandas._libs import (
108
algos as libalgos,
119
hashtable as ht,
@@ -1684,20 +1682,25 @@ def test_unique_complex_numbers(self, array, expected):
16841682

16851683

16861684
class TestHashTable:
1687-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
16881685
@pytest.mark.parametrize(
16891686
"htable, data",
16901687
[
1691-
(ht.PyObjectHashTable, [f"foo_{i}" for i in range(1000)]),
1692-
(ht.StringHashTable, [f"foo_{i}" for i in range(1000)]),
1688+
(
1689+
ht.PyObjectHashTable,
1690+
np.array([f"foo_{i}" for i in range(1000)], dtype=object),
1691+
),
1692+
(
1693+
ht.StringHashTable,
1694+
np.array([f"foo_{i}" for i in range(1000)], dtype=object),
1695+
),
16931696
(ht.Float64HashTable, np.arange(1000, dtype=np.float64)),
16941697
(ht.Int64HashTable, np.arange(1000, dtype=np.int64)),
16951698
(ht.UInt64HashTable, np.arange(1000, dtype=np.uint64)),
16961699
],
16971700
)
16981701
def test_hashtable_unique(self, htable, data, writable):
16991702
# output of maker has guaranteed unique elements
1700-
s = Series(data)
1703+
s = Series(data, dtype=data.dtype)
17011704
if htable == ht.Float64HashTable:
17021705
# add NaN for float column
17031706
s.loc[500] = np.nan
@@ -1724,20 +1727,25 @@ def test_hashtable_unique(self, htable, data, writable):
17241727
reconstr = result_unique[result_inverse]
17251728
tm.assert_numpy_array_equal(reconstr, s_duplicated.values)
17261729

1727-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
17281730
@pytest.mark.parametrize(
17291731
"htable, data",
17301732
[
1731-
(ht.PyObjectHashTable, [f"foo_{i}" for i in range(1000)]),
1732-
(ht.StringHashTable, [f"foo_{i}" for i in range(1000)]),
1733+
(
1734+
ht.PyObjectHashTable,
1735+
np.array([f"foo_{i}" for i in range(1000)], dtype=object),
1736+
),
1737+
(
1738+
ht.StringHashTable,
1739+
np.array([f"foo_{i}" for i in range(1000)], dtype=object),
1740+
),
17331741
(ht.Float64HashTable, np.arange(1000, dtype=np.float64)),
17341742
(ht.Int64HashTable, np.arange(1000, dtype=np.int64)),
17351743
(ht.UInt64HashTable, np.arange(1000, dtype=np.uint64)),
17361744
],
17371745
)
17381746
def test_hashtable_factorize(self, htable, writable, data):
17391747
# output of maker has guaranteed unique elements
1740-
s = Series(data)
1748+
s = Series(data, dtype=data.dtype)
17411749
if htable == ht.Float64HashTable:
17421750
# add NaN for float column
17431751
s.loc[500] = np.nan

0 commit comments

Comments
 (0)