From b3a0d9b541e637545d0d6b13346e3814dce6f87c Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Thu, 30 Jan 2020 20:21:07 -0800 Subject: [PATCH] CLN: remove DatetimelikeDelegateMixin --- pandas/core/indexes/datetimelike.py | 43 +---------------------------- 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/pandas/core/indexes/datetimelike.py b/pandas/core/indexes/datetimelike.py index 0f385d9aba9c5..e123fdd228aaf 100644 --- a/pandas/core/indexes/datetimelike.py +++ b/pandas/core/indexes/datetimelike.py @@ -1,8 +1,7 @@ """ Base and utility classes for tseries type pandas objects. """ -import operator -from typing import Any, List, Optional, Set, Union +from typing import Any, List, Optional, Union import numpy as np @@ -30,7 +29,6 @@ from pandas.core.dtypes.missing import is_valid_nat_for_dtype, isna from pandas.core import algorithms -from pandas.core.accessor import PandasDelegate from pandas.core.arrays import DatetimeArray, PeriodArray, TimedeltaArray from pandas.core.arrays.datetimelike import DatetimeLikeArrayMixin from pandas.core.base import _shared_docs @@ -932,42 +930,3 @@ def insert(self, loc, item): raise TypeError( f"cannot insert {type(self).__name__} with incompatible label" ) - - -class DatetimelikeDelegateMixin(PandasDelegate): - """ - Delegation mechanism, specific for Datetime, Timedelta, and Period types. - - Functionality is delegated from the Index class to an Array class. A - few things can be customized - - * _delegated_methods, delegated_properties : List - The list of property / method names being delagated. - * raw_methods : Set - The set of methods whose results should should *not* be - boxed in an index, after being returned from the array - * raw_properties : Set - The set of properties whose results should should *not* be - boxed in an index, after being returned from the array - """ - - # raw_methods : dispatch methods that shouldn't be boxed in an Index - _raw_methods: Set[str] = set() - # raw_properties : dispatch properties that shouldn't be boxed in an Index - _raw_properties: Set[str] = set() - _data: Union[DatetimeArray, TimedeltaArray, PeriodArray] - - def _delegate_property_get(self, name, *args, **kwargs): - result = getattr(self._data, name) - if name not in self._raw_properties: - result = Index(result, name=self.name) - return result - - def _delegate_property_set(self, name: str, value, *args, **kwargs): - setattr(self._data, name, value) - - def _delegate_method(self, name, *args, **kwargs): - result = operator.methodcaller(name, *args, **kwargs)(self._data) - if name not in self._raw_methods: - result = Index(result, name=self.name) - return result