Skip to content

Commit 151bb8a

Browse files
committed
CompWrapper handles validate_len in add and sub methods
1 parent 7eb28d4 commit 151bb8a

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

pandas/core/arrays/datetimelike.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -988,9 +988,6 @@ def _add_delta_tdi(self, other):
988988
Add a delta of a TimedeltaIndex
989989
return the i8 result view
990990
"""
991-
if len(self) != len(other):
992-
raise ValueError("cannot add indices of unequal length")
993-
994991
if isinstance(other, np.ndarray):
995992
# ndarray[timedelta64]; wrap in TimedeltaIndex for op
996993
from pandas import TimedeltaIndex
@@ -1055,9 +1052,6 @@ def _sub_period_array(self, other):
10551052
.format(dtype=other.dtype,
10561053
cls=type(self).__name__))
10571054

1058-
if len(self) != len(other):
1059-
raise ValueError("cannot subtract arrays/indices of "
1060-
"unequal length")
10611055
if self.freq != other.freq:
10621056
msg = DIFFERENT_FREQ.format(cls=type(self).__name__,
10631057
own_freq=self.freqstr,
@@ -1176,7 +1170,7 @@ def _time_shift(self, periods, freq=None):
11761170
return self._generate_range(start=start, end=end, periods=None,
11771171
freq=self.freq)
11781172

1179-
@CompWrapper(zerodim=True, inst_from_senior_cls=True)
1173+
@CompWrapper(zerodim=True, inst_from_senior_cls=True, validate_len=True)
11801174
def __add__(self, other):
11811175
# scalar others
11821176
if other is NaT:
@@ -1236,7 +1230,7 @@ def __radd__(self, other):
12361230
# alias for __add__
12371231
return self.__add__(other)
12381232

1239-
@CompWrapper(zerodim=True, inst_from_senior_cls=True)
1233+
@CompWrapper(zerodim=True, inst_from_senior_cls=True, validate_len=True)
12401234
def __sub__(self, other):
12411235
# scalar others
12421236
if other is NaT:

0 commit comments

Comments
 (0)