Skip to content

Commit 587008d

Browse files
committed
Wrap add and sub methods with CompWrapper
1 parent 4b46bb9 commit 587008d

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

pandas/core/arrays/datetimelike.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from pandas.core.algorithms import (
3333
checked_add_with_arr, take, unique1d, value_counts)
3434
import pandas.core.common as com
35+
from pandas.core.ops import CompWrapper
3536

3637
from pandas.tseries import frequencies
3738
from pandas.tseries.offsets import DateOffset, Tick
@@ -1175,13 +1176,10 @@ def _time_shift(self, periods, freq=None):
11751176
return self._generate_range(start=start, end=end, periods=None,
11761177
freq=self.freq)
11771178

1179+
@CompWrapper(zerodim=True, inst_from_senior_cls=True)
11781180
def __add__(self, other):
1179-
other = lib.item_from_zerodim(other)
1180-
if isinstance(other, (ABCSeries, ABCDataFrame)):
1181-
return NotImplemented
1182-
11831181
# scalar others
1184-
elif other is NaT:
1182+
if other is NaT:
11851183
result = self._add_nat()
11861184
elif isinstance(other, (Tick, timedelta, np.timedelta64)):
11871185
result = self._add_delta(other)
@@ -1238,13 +1236,10 @@ def __radd__(self, other):
12381236
# alias for __add__
12391237
return self.__add__(other)
12401238

1239+
@CompWrapper(zerodim=True, inst_from_senior_cls=True)
12411240
def __sub__(self, other):
1242-
other = lib.item_from_zerodim(other)
1243-
if isinstance(other, (ABCSeries, ABCDataFrame)):
1244-
return NotImplemented
1245-
12461241
# scalar others
1247-
elif other is NaT:
1242+
if other is NaT:
12481243
result = self._sub_nat()
12491244
elif isinstance(other, (Tick, timedelta, np.timedelta64)):
12501245
result = self._add_delta(-other)

0 commit comments

Comments
 (0)