Skip to content

CLN: remove no-longer-reachable addsub_int_array #30592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions pandas/core/arrays/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -1093,39 +1093,6 @@ def _sub_period_array(self, other):
new_values[mask] = NaT
return new_values

def _addsub_int_array(self, other, op):
"""
Add or subtract array-like of integers equivalent to applying
`_time_shift` pointwise.

Parameters
----------
other : Index, ExtensionArray, np.ndarray
integer-dtype
op : {operator.add, operator.sub}

Returns
-------
result : same class as self
"""
# _addsub_int_array is overridden by PeriodArray
assert not is_period_dtype(self)
assert op in [operator.add, operator.sub]

if self.freq is None:
# GH#19123
raise NullFrequencyError("Cannot shift with no freq")

elif isinstance(self.freq, Tick):
# easy case where we can convert to timedelta64 operation
td = Timedelta(self.freq)
return op(self, td * other)

# We should only get here with DatetimeIndex; dispatch
# to _addsub_offset_array
assert not is_timedelta64_dtype(self)
return op(self, np.array(other) * self.freq)

def _addsub_offset_array(self, other, op):
"""
Add or subtract array-like of DateOffset objects
Expand Down
21 changes: 16 additions & 5 deletions pandas/core/arrays/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,12 +634,23 @@ def _sub_period(self, other):

return new_data

@Appender(dtl.DatetimeLikeArrayMixin._addsub_int_array.__doc__)
def _addsub_int_array(
self,
other: Union[ABCPeriodArray, ABCSeries, ABCPeriodIndex, np.ndarray],
op: Callable[[Any], Any],
) -> ABCPeriodArray:
self, other: np.ndarray, op: Callable[[Any], Any],
) -> "PeriodArray":
"""
Add or subtract array of integers; equivalent to applying
`_time_shift` pointwise.

Parameters
----------
other : np.ndarray[integer-dtype]
op : {operator.add, operator.sub}

Returns
-------
result : PeriodArray
"""

assert op in [operator.add, operator.sub]
if op is operator.sub:
other = -other
Expand Down