|
20 | 20 | pandas_dtype,
|
21 | 21 | )
|
22 | 22 | from pandas.core.dtypes.dtypes import register_extension_dtype
|
23 |
| -from pandas.core.dtypes.generic import ABCDataFrame, ABCIndexClass, ABCSeries |
24 | 23 | from pandas.core.dtypes.missing import isna
|
25 | 24 |
|
26 | 25 | from pandas.core import ops
|
@@ -559,13 +558,10 @@ def all(self, skipna: bool = True, **kwargs):
|
559 | 558 |
|
560 | 559 | @classmethod
|
561 | 560 | def _create_logical_method(cls, op):
|
| 561 | + @ops.unpack_zerodim_and_defer(op.__name__) |
562 | 562 | def logical_method(self, other):
|
563 |
| - if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndexClass)): |
564 |
| - # Rely on pandas to unbox and dispatch to us. |
565 |
| - return NotImplemented |
566 | 563 |
|
567 | 564 | assert op.__name__ in {"or_", "ror_", "and_", "rand_", "xor", "rxor"}
|
568 |
| - other = lib.item_from_zerodim(other) |
569 | 565 | other_is_booleanarray = isinstance(other, BooleanArray)
|
570 | 566 | other_is_scalar = lib.is_scalar(other)
|
571 | 567 | mask = None
|
@@ -605,16 +601,14 @@ def logical_method(self, other):
|
605 | 601 |
|
606 | 602 | @classmethod
|
607 | 603 | def _create_comparison_method(cls, op):
|
| 604 | + @ops.unpack_zerodim_and_defer(op.__name__) |
608 | 605 | def cmp_method(self, other):
|
609 | 606 | from pandas.arrays import IntegerArray
|
610 | 607 |
|
611 |
| - if isinstance( |
612 |
| - other, (ABCDataFrame, ABCSeries, ABCIndexClass, IntegerArray) |
613 |
| - ): |
| 608 | + if isinstance(other, IntegerArray): |
614 | 609 | # Rely on pandas to unbox and dispatch to us.
|
615 | 610 | return NotImplemented
|
616 | 611 |
|
617 |
| - other = lib.item_from_zerodim(other) |
618 | 612 | mask = None
|
619 | 613 |
|
620 | 614 | if isinstance(other, BooleanArray):
|
@@ -693,13 +687,8 @@ def _maybe_mask_result(self, result, mask, other, op_name: str):
|
693 | 687 | def _create_arithmetic_method(cls, op):
|
694 | 688 | op_name = op.__name__
|
695 | 689 |
|
| 690 | + @ops.unpack_zerodim_and_defer(op_name) |
696 | 691 | def boolean_arithmetic_method(self, other):
|
697 |
| - |
698 |
| - if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndexClass)): |
699 |
| - # Rely on pandas to unbox and dispatch to us. |
700 |
| - return NotImplemented |
701 |
| - |
702 |
| - other = lib.item_from_zerodim(other) |
703 | 692 | mask = None
|
704 | 693 |
|
705 | 694 | if isinstance(other, BooleanArray):
|
|
0 commit comments