Skip to content

Commit a2ddaea

Browse files
mroeschkenoatamir
authored andcommitted
BUG: ArrowExtensionArray compared to invalid object not raising (pandas-dev#48833)
1 parent fc53d39 commit a2ddaea

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
@@ -93,7 +93,7 @@ Bug fixes
9393
- Bug in :func:`assert_index_equal` for extension arrays with non matching ``NA`` raising ``ValueError`` (:issue:`48608`)
9494
- Bug in :meth:`DataFrame.pivot_table` raising unexpected ``FutureWarning`` when setting datetime column as index (:issue:`48683`)
9595
- Bug in :meth:`DataFrame.sort_values` emitting unnecessary ``FutureWarning`` when called on :class:`DataFrame` with boolean sparse columns (:issue:`48784`)
96-
-
96+
- Bug in :class:`.arrays.ArrowExtensionArray` with a comparison operator to an invalid object would not raise a ``NotImplementedError`` (:issue:`48833`)
9797

9898
.. ---------------------------------------------------------------------------
9999

pandas/core/arrays/arrow/array.py

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

pandas/tests/extension/test_arrow.py

+7
Original file line numberDiff line numberDiff line change
@@ -1669,6 +1669,13 @@ def test_compare_array(self, data, comparison_op, na_value, request):
16691669
with pytest.raises(type(exc)):
16701670
ser.combine(other, comparison_op)
16711671

1672+
def test_invalid_other_comp(self, data, comparison_op):
1673+
# GH 48833
1674+
with pytest.raises(
1675+
NotImplementedError, match=".* not implemented for <class 'object'>"
1676+
):
1677+
comparison_op(data, object())
1678+
16721679

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

0 commit comments

Comments
 (0)