You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DatetimeArray and TimedeltaArray comparison methods share a lot of code, might be possible to de-duplicate a lot of it by using the new unbox_scalar method:
From DTA:
if isinstance(other, (datetime, np.datetime64, compat.string_types)):
if isinstance(other, (datetime, np.datetime64)):
# GH#18435 strings get a pass from tzawareness compat
self._assert_tzawareness_compat(other)
try:
other = _to_m8(other, tz=self.tz)
except ValueError:
# string that cannot be parsed to Timestamp
return ops.invalid_comparison(self, other, op)
result = op(self.asi8, other.view('i8'))
if isna(other):
result.fill(nat_result)
From TDA:
if _is_convertible_to_td(other) or other is NaT:
try:
other = _to_m8(other)
except ValueError:
# failed to parse as timedelta
return ops.invalid_comparison(self, other, op)
result = meth(self, other)
if isna(other):
result.fill(nat_result)
Note that _to_m8 means something different in these two files.
The _unbox_scalar methods might not be quite the right fit, but the idea behind them is really similar to _is_convertible_to_td and the try/except calls to to_m8.
The text was updated successfully, but these errors were encountered:
DatetimeArray and TimedeltaArray comparison methods share a lot of code, might be possible to de-duplicate a lot of it by using the new unbox_scalar method:
From DTA:
From TDA:
Note that
_to_m8
means something different in these two files.The _unbox_scalar methods might not be quite the right fit, but the idea behind them is really similar to
_is_convertible_to_td
and the try/except calls to to_m8.The text was updated successfully, but these errors were encountered: