Skip to content

Commit e5f6d1d

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

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

pandas/tests/copy_view/test_interp_fillna.py

+4-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 import (
75
NA,
86
ArrowDtype,
@@ -137,10 +135,9 @@ def test_interp_fill_functions_inplace(
137135
assert np.shares_memory(arr, get_array(df, "a")) is (dtype == "float64")
138136

139137

140-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
141-
def test_interpolate_cleaned_fill_method(using_copy_on_write):
142-
# Check that "method is set to None" case works correctly
138+
def test_interpolate_cannot_with_object_dtype(using_copy_on_write):
143139
df = DataFrame({"a": ["a", np.nan, "c"], "b": 1})
140+
df["a"] = df["a"].astype(object)
144141
df_orig = df.copy()
145142

146143
msg = "DataFrame.interpolate with object dtype"
@@ -159,9 +156,9 @@ def test_interpolate_cleaned_fill_method(using_copy_on_write):
159156
tm.assert_frame_equal(df, df_orig)
160157

161158

162-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
163-
def test_interpolate_object_convert_no_op(using_copy_on_write):
159+
def test_interpolate_object_convert_no_op(using_copy_on_write, using_infer_string):
164160
df = DataFrame({"a": ["a", "b", "c"], "b": 1})
161+
df["a"] = df["a"].astype(object)
165162
arr_a = get_array(df, "a")
166163
msg = "DataFrame.interpolate with method=pad is deprecated"
167164
with tm.assert_produces_warning(FutureWarning, match=msg):

pandas/tests/copy_view/test_replace.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,9 @@ def test_replace_empty_list(using_copy_on_write):
356356
assert not df2._mgr._has_no_reference(0)
357357

358358

359-
@pytest.mark.xfail(using_string_dtype() and HAS_PYARROW, reason="TODO(infer_string)")
360359
@pytest.mark.parametrize("value", ["d", None])
361360
def test_replace_object_list_inplace(using_copy_on_write, value):
362-
df = DataFrame({"a": ["a", "b", "c"]})
361+
df = DataFrame({"a": ["a", "b", "c"]}, dtype=object)
363362
arr = get_array(df, "a")
364363
df.replace(["c"], value, inplace=True)
365364
if using_copy_on_write or value is None:

pandas/tests/test_algos.py

+18-8
Original file line numberDiff line numberDiff line change
@@ -1704,20 +1704,25 @@ def test_unique_complex_numbers(self, array, expected):
17041704

17051705

17061706
class TestHashTable:
1707-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
17081707
@pytest.mark.parametrize(
17091708
"htable, data",
17101709
[
1711-
(ht.PyObjectHashTable, [f"foo_{i}" for i in range(1000)]),
1712-
(ht.StringHashTable, [f"foo_{i}" for i in range(1000)]),
1710+
(
1711+
ht.PyObjectHashTable,
1712+
np.array([f"foo_{i}" for i in range(1000)], dtype=object),
1713+
),
1714+
(
1715+
ht.StringHashTable,
1716+
np.array([f"foo_{i}" for i in range(1000)], dtype=object),
1717+
),
17131718
(ht.Float64HashTable, np.arange(1000, dtype=np.float64)),
17141719
(ht.Int64HashTable, np.arange(1000, dtype=np.int64)),
17151720
(ht.UInt64HashTable, np.arange(1000, dtype=np.uint64)),
17161721
],
17171722
)
17181723
def test_hashtable_unique(self, htable, data, writable):
17191724
# output of maker has guaranteed unique elements
1720-
s = Series(data)
1725+
s = Series(data, dtype=data.dtype)
17211726
if htable == ht.Float64HashTable:
17221727
# add NaN for float column
17231728
s.loc[500] = np.nan
@@ -1744,20 +1749,25 @@ def test_hashtable_unique(self, htable, data, writable):
17441749
reconstr = result_unique[result_inverse]
17451750
tm.assert_numpy_array_equal(reconstr, s_duplicated.values)
17461751

1747-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
17481752
@pytest.mark.parametrize(
17491753
"htable, data",
17501754
[
1751-
(ht.PyObjectHashTable, [f"foo_{i}" for i in range(1000)]),
1752-
(ht.StringHashTable, [f"foo_{i}" for i in range(1000)]),
1755+
(
1756+
ht.PyObjectHashTable,
1757+
np.array([f"foo_{i}" for i in range(1000)], dtype=object),
1758+
),
1759+
(
1760+
ht.StringHashTable,
1761+
np.array([f"foo_{i}" for i in range(1000)], dtype=object),
1762+
),
17531763
(ht.Float64HashTable, np.arange(1000, dtype=np.float64)),
17541764
(ht.Int64HashTable, np.arange(1000, dtype=np.int64)),
17551765
(ht.UInt64HashTable, np.arange(1000, dtype=np.uint64)),
17561766
],
17571767
)
17581768
def test_hashtable_factorize(self, htable, writable, data):
17591769
# output of maker has guaranteed unique elements
1760-
s = Series(data)
1770+
s = Series(data, dtype=data.dtype)
17611771
if htable == ht.Float64HashTable:
17621772
# add NaN for float column
17631773
s.loc[500] = np.nan

0 commit comments

Comments
 (0)