(
self, target: Index, indexer: npt.NDArray[np.intp]
)
| 4012 | |
| 4013 | @final |
| 4014 | def _difference_compat( |
| 4015 | self, target: Index, indexer: npt.NDArray[np.intp] |
| 4016 | ) -> ArrayLike: |
| 4017 | # Compatibility for PeriodArray, for which __sub__ returns an ndarray[object] |
| 4018 | # of DateOffset objects, which do not support __abs__ (and would be slow |
| 4019 | # if they did) |
| 4020 | |
| 4021 | if isinstance(self.dtype, PeriodDtype): |
| 4022 | # Note: we only get here with matching dtypes |
| 4023 | own_values = cast("PeriodArray", self._data)._ndarray |
| 4024 | target_values = cast("PeriodArray", target._data)._ndarray |
| 4025 | diff = own_values[indexer] - target_values |
| 4026 | else: |
| 4027 | # error: Unsupported left operand type for - ("ExtensionArray") |
| 4028 | diff = self._values[indexer] - target._values # type: ignore[operator] |
| 4029 | return abs(diff) |
| 4030 | |
| 4031 | # -------------------------------------------------------------------- |
| 4032 | # Indexer Conversion Methods |
no outgoing calls
no test coverage detected