Skip to content

CLN: Timestamp unused attrs, annotations #34216

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
May 17, 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
2 changes: 1 addition & 1 deletion pandas/_libs/tslibs/timestamps.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 8 additions & 18 deletions pandas/_libs/tslibs/timestamps.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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.
"""
Expand Down Expand Up @@ -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.
"""
Expand All @@ -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.
"""
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down