|
34 | 34 | from pandas.util._decorators import doc
|
35 | 35 |
|
36 | 36 | from pandas.core.dtypes.common import (
|
37 |
| - is_bool_dtype, |
38 | 37 | is_datetime64_any_dtype,
|
39 | 38 | is_float,
|
40 | 39 | is_integer,
|
@@ -350,42 +349,6 @@ def __contains__(self, key: Any) -> bool:
|
350 | 349 | # ------------------------------------------------------------------------
|
351 | 350 | # Index Methods
|
352 | 351 |
|
353 |
| - def __array_wrap__(self, result, context=None): |
354 |
| - """ |
355 |
| - Gets called after a ufunc and other functions. |
356 |
| -
|
357 |
| - Needs additional handling as PeriodIndex stores internal data as int |
358 |
| - dtype |
359 |
| -
|
360 |
| - Replace this to __numpy_ufunc__ in future version and implement |
361 |
| - __array_function__ for Indexes |
362 |
| - """ |
363 |
| - if isinstance(context, tuple) and len(context) > 0: |
364 |
| - func = context[0] |
365 |
| - if func is np.add: |
366 |
| - pass |
367 |
| - elif func is np.subtract: |
368 |
| - name = self.name |
369 |
| - left = context[1][0] |
370 |
| - right = context[1][1] |
371 |
| - if isinstance(left, PeriodIndex) and isinstance(right, PeriodIndex): |
372 |
| - name = left.name if left.name == right.name else None |
373 |
| - return Index(result, name=name) |
374 |
| - elif isinstance(left, Period) or isinstance(right, Period): |
375 |
| - return Index(result, name=name) |
376 |
| - elif isinstance(func, np.ufunc): |
377 |
| - if "M->M" not in func.types: |
378 |
| - msg = f"ufunc '{func.__name__}' not supported for the PeriodIndex" |
379 |
| - # This should be TypeError, but TypeError cannot be raised |
380 |
| - # from here because numpy catches. |
381 |
| - raise ValueError(msg) |
382 |
| - |
383 |
| - if is_bool_dtype(result): |
384 |
| - return result |
385 |
| - # the result is object dtype array of Period |
386 |
| - # cannot pass _simple_new as it is |
387 |
| - return type(self)(result, freq=self.freq, name=self.name) |
388 |
| - |
389 | 352 | def asof_locs(self, where: Index, mask: np.ndarray) -> np.ndarray:
|
390 | 353 | """
|
391 | 354 | where : array of timestamps
|
|
0 commit comments