SUMM: Consistent Casting and Length Checks in Ops #37086
Labels
API - Consistency
Internal Consistency of API/Behavior
Numeric Operations
Arithmetic, Comparison, and Logical operations
xref #27911 API: when to cast list-like to ndarray, check len match
xref #13637 API: Index/Series/DataFrame op 1-d list-like coercion
Related bugs:
#21517 Comparison of MultiIndex to tuple interprets tuple as collection
One way to ensure consistent behavior is to enshrine it in
ops.unpack_zerodim_and_defer
, which just about all of our ops now use. The following is an implementation that matches our current behavior (more specifically: passes current tests) when tacked on to unpack_zerodim_and_defer, with one exception, described below:The sticking point is what we do when we have a listlike that is not array-like, generally list or tuple. In this implementation, we would treat it as arraylike whenever we are not object-dtype, and keep it as-is otherwise.
The test that fails with this has a length-1 list:
ATM in
array_ops.logical_op
we cast list (only list, not tuple) tondarray[object]
. The implementation above would make this raise ValueError.Outstanding questions:
The text was updated successfully, but these errors were encountered: