|
23 | 23 | pandas_dtype,
|
24 | 24 | )
|
25 | 25 | from pandas.core.dtypes.dtypes import register_extension_dtype
|
26 |
| -from pandas.core.dtypes.generic import ABCDataFrame, ABCIndexClass, ABCSeries |
27 | 26 | from pandas.core.dtypes.missing import isna
|
28 | 27 |
|
29 | 28 | from pandas.core import nanops, ops
|
@@ -584,13 +583,10 @@ def all(self, skipna: bool = True, **kwargs):
|
584 | 583 |
|
585 | 584 | @classmethod
|
586 | 585 | def _create_logical_method(cls, op):
|
| 586 | + @ops.unpack_zerodim_and_defer(op.__name__) |
587 | 587 | def logical_method(self, other):
|
588 |
| - if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndexClass)): |
589 |
| - # Rely on pandas to unbox and dispatch to us. |
590 |
| - return NotImplemented |
591 | 588 |
|
592 | 589 | assert op.__name__ in {"or_", "ror_", "and_", "rand_", "xor", "rxor"}
|
593 |
| - other = lib.item_from_zerodim(other) |
594 | 590 | other_is_booleanarray = isinstance(other, BooleanArray)
|
595 | 591 | other_is_scalar = lib.is_scalar(other)
|
596 | 592 | mask = None
|
@@ -630,16 +626,14 @@ def logical_method(self, other):
|
630 | 626 |
|
631 | 627 | @classmethod
|
632 | 628 | def _create_comparison_method(cls, op):
|
| 629 | + @ops.unpack_zerodim_and_defer(op.__name__) |
633 | 630 | def cmp_method(self, other):
|
634 | 631 | from pandas.arrays import IntegerArray
|
635 | 632 |
|
636 |
| - if isinstance( |
637 |
| - other, (ABCDataFrame, ABCSeries, ABCIndexClass, IntegerArray) |
638 |
| - ): |
| 633 | + if isinstance(other, IntegerArray): |
639 | 634 | # Rely on pandas to unbox and dispatch to us.
|
640 | 635 | return NotImplemented
|
641 | 636 |
|
642 |
| - other = lib.item_from_zerodim(other) |
643 | 637 | mask = None
|
644 | 638 |
|
645 | 639 | if isinstance(other, BooleanArray):
|
@@ -735,13 +729,8 @@ def _maybe_mask_result(self, result, mask, other, op_name: str):
|
735 | 729 | def _create_arithmetic_method(cls, op):
|
736 | 730 | op_name = op.__name__
|
737 | 731 |
|
| 732 | + @ops.unpack_zerodim_and_defer(op_name) |
738 | 733 | def boolean_arithmetic_method(self, other):
|
739 |
| - |
740 |
| - if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndexClass)): |
741 |
| - # Rely on pandas to unbox and dispatch to us. |
742 |
| - return NotImplemented |
743 |
| - |
744 |
| - other = lib.item_from_zerodim(other) |
745 | 734 | mask = None
|
746 | 735 |
|
747 | 736 | if isinstance(other, BooleanArray):
|
|
0 commit comments