Skip to content

Commit a087f3e

Browse files
authored
REF: cdef BusinessHourMixin (#34342)
1 parent 01853fc commit a087f3e

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

doc/source/reference/offset_frequency.rst

+4
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ Properties
9393
BusinessHour.normalize
9494
BusinessHour.rule_code
9595
BusinessHour.n
96+
BusinessHour.start
97+
BusinessHour.end
9698

9799
Methods
98100
~~~~~~~
@@ -159,6 +161,8 @@ Properties
159161
CustomBusinessHour.normalize
160162
CustomBusinessHour.rule_code
161163
CustomBusinessHour.n
164+
CustomBusinessHour.start
165+
CustomBusinessHour.end
162166

163167
Methods
164168
~~~~~~~

pandas/_libs/tslibs/offsets.pyx

+12-7
Original file line numberDiff line numberDiff line change
@@ -747,11 +747,13 @@ cdef class BaseOffset:
747747
self.__dict__.update(state)
748748

749749
if 'weekmask' in state and 'holidays' in state:
750-
calendar, holidays = _get_calendar(weekmask=self.weekmask,
751-
holidays=self.holidays,
750+
weekmask = state.pop("weekmask")
751+
holidays = state.pop("holidays")
752+
calendar, holidays = _get_calendar(weekmask=weekmask,
753+
holidays=holidays,
752754
calendar=None)
753-
object.__setattr__(self, "calendar", calendar)
754-
object.__setattr__(self, "holidays", holidays)
755+
self.calendar = calendar
756+
self.holidays = holidays
755757

756758
def __getstate__(self):
757759
"""Return a pickleable state"""
@@ -1043,9 +1045,12 @@ cdef class BusinessMixin(SingleConstructorOffset):
10431045
BaseOffset.__setstate__(self, state)
10441046

10451047

1046-
class BusinessHourMixin(BusinessMixin):
1048+
cdef class BusinessHourMixin(BusinessMixin):
10471049
_adjust_dst = False
10481050

1051+
cdef readonly:
1052+
tuple start, end
1053+
10491054
def __init__(
10501055
self, n=1, normalize=False, start="09:00", end="17:00", offset=timedelta(0)
10511056
):
@@ -1092,8 +1097,8 @@ class BusinessHourMixin(BusinessMixin):
10921097
"one another"
10931098
)
10941099

1095-
object.__setattr__(self, "start", start)
1096-
object.__setattr__(self, "end", end)
1100+
self.start = start
1101+
self.end = end
10971102

10981103
def __reduce__(self):
10991104
return type(self), (self.n, self.normalize, self.start, self.end, self.offset)

0 commit comments

Comments
 (0)