Skip to content

Commit 946abca

Browse files
fix failures
1 parent 649dad1 commit 946abca

File tree

6 files changed

+28
-64
lines changed

6 files changed

+28
-64
lines changed

pandas/core/arrays/string_.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,8 +825,8 @@ def _cmp_method(self, other, op):
825825
f"Lengths of operands do not match: {len(self)} != {len(other)}"
826826
)
827827

828-
other = np.asarray(other)
829828
other = other[valid]
829+
other = np.asarray(other)
830830

831831
if op.__name__ in ops.ARITHMETIC_BINOPS:
832832
result = np.empty_like(self._ndarray, dtype="object")

pandas/tests/arrays/integer/test_arithmetic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def test_numpy_zero_dim_ndarray(other):
172172
# -----------------------------------------------------------------------------
173173

174174

175-
def test_error_invalid_values(data, all_arithmetic_operators, using_infer_string):
175+
def test_error_invalid_values(data, all_arithmetic_operators):
176176
op = all_arithmetic_operators
177177
s = pd.Series(data)
178178
ops = getattr(s, op)

pandas/tests/frame/test_logical_ops.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
import numpy as np
55
import pytest
66

7-
from pandas._config import using_string_dtype
8-
9-
from pandas.compat import HAS_PYARROW
10-
117
from pandas import (
128
CategoricalIndex,
139
DataFrame,
@@ -100,9 +96,6 @@ def test_logical_ops_int_frame(self):
10096
res_ser = df1a_int["A"] | df1a_bool["A"]
10197
tm.assert_series_equal(res_ser, df1a_bool["A"])
10298

103-
@pytest.mark.xfail(
104-
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)"
105-
)
10699
def test_logical_ops_invalid(self, using_infer_string):
107100
# GH#5808
108101

@@ -114,15 +107,12 @@ def test_logical_ops_invalid(self, using_infer_string):
114107

115108
df1 = DataFrame("foo", index=[1], columns=["A"])
116109
df2 = DataFrame(True, index=[1], columns=["A"])
117-
msg = re.escape("unsupported operand type(s) for |: 'str' and 'bool'")
118-
if using_infer_string:
119-
import pyarrow as pa
120-
121-
with pytest.raises(pa.lib.ArrowNotImplementedError, match="|has no kernel"):
122-
df1 | df2
110+
if using_infer_string and df1["A"].dtype.storage == "pyarrow":
111+
msg = "operation 'or_' not supported for dtype 'str'"
123112
else:
124-
with pytest.raises(TypeError, match=msg):
125-
df1 | df2
113+
msg = re.escape("unsupported operand type(s) for |: 'str' and 'bool'")
114+
with pytest.raises(TypeError, match=msg):
115+
df1 | df2
126116

127117
def test_logical_operators(self):
128118
def _check_bin_op(op):

pandas/tests/indexes/object/test_indexing.py

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
import numpy as np
44
import pytest
55

6-
from pandas._config import using_string_dtype
7-
86
from pandas._libs.missing import (
97
NA,
108
is_matching_na,
119
)
12-
from pandas.compat import HAS_PYARROW
1310
import pandas.util._test_decorators as td
1411

1512
import pandas as pd
@@ -32,39 +29,25 @@ def test_get_indexer_strings(self, method, expected):
3229

3330
tm.assert_numpy_array_equal(actual, expected)
3431

35-
@pytest.mark.xfail(
36-
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)"
37-
)
3832
def test_get_indexer_strings_raises(self, using_infer_string):
3933
index = Index(["b", "c"])
4034

41-
if using_infer_string:
42-
import pyarrow as pa
43-
44-
msg = "has no kernel"
45-
with pytest.raises(pa.lib.ArrowNotImplementedError, match=msg):
46-
index.get_indexer(["a", "b", "c", "d"], method="nearest")
47-
48-
with pytest.raises(pa.lib.ArrowNotImplementedError, match=msg):
49-
index.get_indexer(["a", "b", "c", "d"], method="pad", tolerance=2)
50-
51-
with pytest.raises(pa.lib.ArrowNotImplementedError, match=msg):
52-
index.get_indexer(
53-
["a", "b", "c", "d"], method="pad", tolerance=[2, 2, 2, 2]
54-
)
55-
56-
else:
57-
msg = r"unsupported operand type\(s\) for -: 'str' and 'str'"
58-
with pytest.raises(TypeError, match=msg):
59-
index.get_indexer(["a", "b", "c", "d"], method="nearest")
35+
msg = "|".join(
36+
[
37+
"operation 'sub' not supported for dtype 'str'",
38+
r"unsupported operand type\(s\) for -: 'str' and 'str'",
39+
]
40+
)
41+
with pytest.raises(TypeError, match=msg):
42+
index.get_indexer(["a", "b", "c", "d"], method="nearest")
6043

61-
with pytest.raises(TypeError, match=msg):
62-
index.get_indexer(["a", "b", "c", "d"], method="pad", tolerance=2)
44+
with pytest.raises(TypeError, match=msg):
45+
index.get_indexer(["a", "b", "c", "d"], method="pad", tolerance=2)
6346

64-
with pytest.raises(TypeError, match=msg):
65-
index.get_indexer(
66-
["a", "b", "c", "d"], method="pad", tolerance=[2, 2, 2, 2]
67-
)
47+
with pytest.raises(TypeError, match=msg):
48+
index.get_indexer(
49+
["a", "b", "c", "d"], method="pad", tolerance=[2, 2, 2, 2]
50+
)
6851

6952
def test_get_indexer_with_NA_values(
7053
self, unique_nulls_fixture, unique_nulls_fixture2

pandas/tests/series/test_arithmetic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,9 @@ def test_series_integer_mod(self, index):
214214
s1 = Series(range(1, 10))
215215
s2 = Series("foo", index=index)
216216

217-
msg = "not all arguments converted during string formatting|mod not"
217+
msg = "not all arguments converted during string formatting|'mod' not supported"
218218

219-
with pytest.raises((TypeError, NotImplementedError), match=msg):
219+
with pytest.raises(TypeError, match=msg):
220220
s2 % s1
221221

222222
def test_add_with_duplicate_index(self):

pandas/tests/series/test_logical_ops.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
from pandas._config import using_string_dtype
88

9-
from pandas.compat import HAS_PYARROW
10-
119
from pandas import (
1210
ArrowDtype,
1311
DataFrame,
@@ -146,10 +144,7 @@ def test_logical_operators_int_dtype_with_bool(self):
146144
expected = Series([False, True, True, True])
147145
tm.assert_series_equal(result, expected)
148146

149-
@pytest.mark.xfail(
150-
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)"
151-
)
152-
def test_logical_operators_int_dtype_with_object(self, using_infer_string):
147+
def test_logical_operators_int_dtype_with_object(self):
153148
# GH#9016: support bitwise op for integer types
154149
s_0123 = Series(range(4), dtype="int64")
155150

@@ -158,14 +153,10 @@ def test_logical_operators_int_dtype_with_object(self, using_infer_string):
158153
tm.assert_series_equal(result, expected)
159154

160155
s_abNd = Series(["a", "b", np.nan, "d"])
161-
if using_infer_string:
162-
import pyarrow as pa
163-
164-
with pytest.raises(pa.lib.ArrowNotImplementedError, match="has no kernel"):
165-
s_0123 & s_abNd
166-
else:
167-
with pytest.raises(TypeError, match="unsupported.* 'int' and 'str'"):
168-
s_0123 & s_abNd
156+
with pytest.raises(
157+
TypeError, match="unsupported.* 'int' and 'str'|'rand_' not supported"
158+
):
159+
s_0123 & s_abNd
169160

170161
def test_logical_operators_bool_dtype_with_int(self):
171162
index = list("bca")

0 commit comments

Comments
 (0)