From 28a762245163dd0c0bc7539d28c652305bb1989a Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Sat, 23 May 2020 08:43:42 -0700 Subject: [PATCH 1/3] REF: cdef BusinessHourMixin --- pandas/_libs/tslibs/offsets.pyx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index f9ddb6fabc7bb..8e97404afa03f 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -1024,9 +1024,12 @@ cdef class BusinessMixin(SingleConstructorOffset): self._offset = state["_offset"] -class BusinessHourMixin(BusinessMixin): +cdef class BusinessHourMixin(BusinessMixin): _adjust_dst = False + cdef readonly: + tuple start, end + def __init__( self, n=1, normalize=False, start="09:00", end="17:00", offset=timedelta(0) ): @@ -1073,8 +1076,8 @@ class BusinessHourMixin(BusinessMixin): "one another" ) - object.__setattr__(self, "start", start) - object.__setattr__(self, "end", end) + self.start = start + self.end = end def __reduce__(self): return type(self), (self.n, self.normalize, self.start, self.end, self.offset) From 54ff20b78c93b05f742ef28c3098b1ac7afead67 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Sat, 23 May 2020 09:25:40 -0700 Subject: [PATCH 2/3] doc fixup --- doc/source/reference/offset_frequency.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/source/reference/offset_frequency.rst b/doc/source/reference/offset_frequency.rst index 008f06a2c4999..93dd44ee4f8ab 100644 --- a/doc/source/reference/offset_frequency.rst +++ b/doc/source/reference/offset_frequency.rst @@ -93,6 +93,8 @@ Properties BusinessHour.normalize BusinessHour.rule_code BusinessHour.n + BusinessHour.start + BusinessHour.end Methods ~~~~~~~ @@ -159,6 +161,8 @@ Properties CustomBusinessHour.normalize CustomBusinessHour.rule_code CustomBusinessHour.n + CustomBusinessHour.start + CustomBusinessHour.end Methods ~~~~~~~ From 04df90ef4b935b74483d48aaa1c17c632f9f0e92 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Sat, 23 May 2020 13:07:35 -0700 Subject: [PATCH 3/3] pickle troubleshoot --- pandas/_libs/tslibs/offsets.pyx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index 8e97404afa03f..384036633398e 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -731,11 +731,13 @@ cdef class BaseOffset: self.__dict__.update(state) if 'weekmask' in state and 'holidays' in state: - calendar, holidays = _get_calendar(weekmask=self.weekmask, - holidays=self.holidays, + weekmask = state.pop("weekmask") + holidays = state.pop("holidays") + calendar, holidays = _get_calendar(weekmask=weekmask, + holidays=holidays, calendar=None) - object.__setattr__(self, "calendar", calendar) - object.__setattr__(self, "holidays", holidays) + self.calendar = calendar + self.holidays = holidays def __getstate__(self): """Return a pickleable state"""