Skip to content

Commit 9ec4a91

Browse files
TST (string dtype): fix invalid comparison error message and update test (#60176)
1 parent fc0301d commit 9ec4a91

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

pandas/core/arrays/arrow/array.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ def _cmp_method(self, other, op) -> ArrowExtensionArray:
734734
try:
735735
result[valid] = op(np_array[valid], other)
736736
except TypeError:
737-
result = ops.invalid_comparison(np_array, other, op)
737+
result = ops.invalid_comparison(self, other, op)
738738
result = pa.array(result, type=pa.bool_())
739739
result = pc.if_else(valid, result, None)
740740
else:

pandas/tests/frame/test_arithmetic.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
from pandas._config import using_string_dtype
1515

16-
from pandas.compat import HAS_PYARROW
17-
1816
import pandas as pd
1917
from pandas import (
2018
DataFrame,
@@ -1544,17 +1542,19 @@ def test_comparisons(self, simple_frame, float_frame, func):
15441542
with pytest.raises(ValueError, match=msg):
15451543
func(simple_frame, simple_frame[:2])
15461544

1547-
@pytest.mark.xfail(
1548-
using_string_dtype() and HAS_PYARROW, reason="TODO(infer_string)"
1549-
)
15501545
def test_strings_to_numbers_comparisons_raises(self, compare_operators_no_eq_ne):
15511546
# GH 11565
15521547
df = DataFrame(
15531548
{x: {"x": "foo", "y": "bar", "z": "baz"} for x in ["a", "b", "c"]}
15541549
)
15551550

15561551
f = getattr(operator, compare_operators_no_eq_ne)
1557-
msg = "'[<>]=?' not supported between instances of 'str' and 'int'"
1552+
msg = "|".join(
1553+
[
1554+
"'[<>]=?' not supported between instances of 'str' and 'int'",
1555+
"Invalid comparison between dtype=str and int",
1556+
]
1557+
)
15581558
with pytest.raises(TypeError, match=msg):
15591559
f(df, 0)
15601560

0 commit comments

Comments
 (0)