Skip to content

Commit c91e603

Browse files
Backport PR #48833 on branch 1.5.x (BUG: ArrowExtensionArray compared to invalid object not raising) (#48878)
Backport PR #48833: BUG: ArrowExtensionArray compared to invalid object not raising Co-authored-by: Matthew Roeschke <[email protected]>
1 parent 98948fc commit c91e603

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

doc/source/whatsnew/v1.5.1.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Bug fixes
9494
- Bug in :func:`assert_index_equal` for extension arrays with non matching ``NA`` raising ``ValueError`` (:issue:`48608`)
9595
- Bug in :meth:`DataFrame.pivot_table` raising unexpected ``FutureWarning`` when setting datetime column as index (:issue:`48683`)
9696
- Bug in :meth:`DataFrame.sort_values` emitting unnecessary ``FutureWarning`` when called on :class:`DataFrame` with boolean sparse columns (:issue:`48784`)
97-
-
97+
- Bug in :class:`.arrays.ArrowExtensionArray` with a comparison operator to an invalid object would not raise a ``NotImplementedError`` (:issue:`48833`)
9898

9999
.. ---------------------------------------------------------------------------
100100

pandas/core/arrays/arrow/array.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ def _cmp_method(self, other, op):
390390
result[valid] = op(np.array(self)[valid], other)
391391
return BooleanArray(result, mask)
392392
else:
393-
return NotImplementedError(
393+
raise NotImplementedError(
394394
f"{op.__name__} not implemented for {type(other)}"
395395
)
396396

pandas/tests/extension/test_arrow.py

+7
Original file line numberDiff line numberDiff line change
@@ -1620,6 +1620,13 @@ def test_compare_array(self, data, comparison_op, na_value, request):
16201620
with pytest.raises(type(exc)):
16211621
ser.combine(other, comparison_op)
16221622

1623+
def test_invalid_other_comp(self, data, comparison_op):
1624+
# GH 48833
1625+
with pytest.raises(
1626+
NotImplementedError, match=".* not implemented for <class 'object'>"
1627+
):
1628+
comparison_op(data, object())
1629+
16231630

16241631
def test_arrowdtype_construct_from_string_type_with_unsupported_parameters():
16251632
with pytest.raises(NotImplementedError, match="Passing pyarrow type"):

0 commit comments

Comments
 (0)