Skip to content

Commit 8db5a5f

Browse files
Improve checks using PyArray_IsAnyScalar to verify scalars aren't compared to arrays
1 parent 40bb0ca commit 8db5a5f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pandas/_libs/lib.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,8 @@ def array_equivalent_object(left: object[:], right: object[:]) -> bool:
581581
return False
582582
elif (x is C_NA) ^ (y is C_NA):
583583
return False
584-
elif np.size(x) != np.size(y):
584+
# Only compare scalars to scalars and arrays to arrays
585+
elif cnp.PyArray_IsAnyScalar(x) != cnp.PyArray_IsAnyScalar(y):
585586
return False
586587
elif not (PyObject_RichCompareBool(x, y, Py_EQ) or
587588
(x is None or is_nan(x)) and (y is None or is_nan(y))):

0 commit comments

Comments
 (0)