-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
BUG: Fix logical method Non 1D Extension Arrays #61869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Now, ExtensionArrays handle these cases like NumPy arrays do by returning NotImplemented when they can’t perform the operation. |
@@ -379,7 +379,7 @@ def _logical_method(self, other, op): # type: ignore[override] | |||
elif is_list_like(other): | |||
other = np.asarray(other, dtype="bool") | |||
if other.ndim > 1: | |||
raise NotImplementedError("can only perform ops with 1-d structures") | |||
return NotImplemented |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add tests that this fixes the relevant bug
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to clarify, do you want the fallback behavior to remain as returning NotImplemented
(as in my current code), or some other behavior?
Also, would you prefer the test cases go in a new file like pandas/tests/extension/test_logical_ops_2d_extension.py
, or is there a more appropriate existing file?
Appreciate your guidance!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try writing a test matching the OP example in the linked issue
id put it in tests/arithmetic/test_numeric.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
returning NotImplemented is not the thing we care about. we care about the end result of the arithmetic operation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd expect np_array * ea_array to return an ExtensionArray
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.