From 62b0d1e56ae3d0a271b16c55c193b0b0268d0b00 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Sat, 16 May 2020 13:54:00 -0700 Subject: [PATCH] CLN: Timestamp unused attrs --- pandas/_libs/tslibs/timestamps.pxd | 2 +- pandas/_libs/tslibs/timestamps.pyx | 26 ++++++++------------------ 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/pandas/_libs/tslibs/timestamps.pxd b/pandas/_libs/tslibs/timestamps.pxd index 90f50e3af503c..88d21b19e1e37 100644 --- a/pandas/_libs/tslibs/timestamps.pxd +++ b/pandas/_libs/tslibs/timestamps.pxd @@ -15,7 +15,7 @@ cdef class _Timestamp(ABCTimestamp): cdef readonly: int64_t value, nanosecond object freq - list _date_attributes + cpdef bint _get_start_end_field(self, str field) cpdef _get_date_name_field(self, object field, object locale) cdef int64_t _maybe_convert_value_to_local(self) diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index 0982cf8e5da33..4f8b85240c79f 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -387,6 +387,10 @@ cdef class _Timestamp(ABCTimestamp): dtype=object, ) + elif not isinstance(self, _Timestamp): + # cython semantics, args have been switched and this is __radd__ + return other.__add__(self) + return NotImplemented def __sub__(self, other): @@ -1051,7 +1055,7 @@ timedelta}, default 'raise' return Period(self, freq=freq) @property - def dayofweek(self): + def dayofweek(self) -> int: """ Return day of the week. """ @@ -1092,7 +1096,7 @@ timedelta}, default 'raise' return self._get_date_name_field('month_name', locale) @property - def dayofyear(self): + def dayofyear(self) -> int: """ Return the day of the year. """ @@ -1115,7 +1119,7 @@ timedelta}, default 'raise' return ((self.month - 1) // 3) + 1 @property - def days_in_month(self): + def days_in_month(self) -> int: """ Return the number of days in the month. """ @@ -1428,16 +1432,7 @@ default 'raise' return base1 + base2 - def _has_time_component(self) -> bool: - """ - Returns if the Timestamp has a time component - in addition to the date part - """ - return (self.time() != _zero_time - or self.tzinfo is not None - or self.nanosecond != 0) - - def to_julian_date(self): + def to_julian_date(self) -> np.float64: """ Convert TimeStamp to a Julian Date. 0 Julian date is noon January 1, 4713 BC. @@ -1474,11 +1469,6 @@ default 'raise' np.array([self.value], dtype='i8'), tz=self.tz)[0] return Timestamp(normalized_value).tz_localize(self.tz) - def __radd__(self, other): - # __radd__ on cython extension types like _Timestamp is not used, so - # define it here instead - return self + other - # Add the min and max fields at the class level cdef int64_t _NS_UPPER_BOUND = np.iinfo(np.int64).max