From 024eff907e28e59d64e97a014398e5c23e841460 Mon Sep 17 00:00:00 2001 From: Brock Date: Wed, 3 Jun 2020 17:27:02 -0700 Subject: [PATCH 1/4] CLN: fix liboffsets kludge --- pandas/_libs/tslibs/offsets.pyx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index 77b60d0c22322..c217f37587529 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -1292,11 +1292,7 @@ cdef class BusinessDay(BusinessMixin): self._offset = state.pop("_offset") elif "offset" in state: self._offset = state.pop("offset") - - @property - def _params(self): - # FIXME: using cache_readonly breaks a pytables test - return BaseOffset._params.func(self) + self._cache = state.pop("_cache", {}) def _offset_str(self) -> str: def get_str(td): From 38f2114d98f66de617d3793170486df9a41dd1c8 Mon Sep 17 00:00:00 2001 From: Brock Date: Wed, 3 Jun 2020 18:54:51 -0700 Subject: [PATCH 2/4] CLN: tabs --- pandas/_libs/tslibs/offsets.pxd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/_libs/tslibs/offsets.pxd b/pandas/_libs/tslibs/offsets.pxd index 2b8ad97b83917..9a9244db4a565 100644 --- a/pandas/_libs/tslibs/offsets.pxd +++ b/pandas/_libs/tslibs/offsets.pxd @@ -5,7 +5,7 @@ cdef bint is_offset_object(object obj) cdef bint is_tick_object(object obj) cdef class BaseOffset: - cdef readonly: - int64_t n - bint normalize - dict _cache + cdef readonly: + int64_t n + bint normalize + dict _cache From 524d6f86a353c1e8f293ea87589bd62b3cb25974 Mon Sep 17 00:00:00 2001 From: Brock Date: Wed, 3 Jun 2020 18:57:02 -0700 Subject: [PATCH 3/4] typo fixu[ --- pandas/_libs/tslibs/offsets.pyx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index c217f37587529..b292e40a3b2c1 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -1379,8 +1379,6 @@ cdef class BusinessDay(BusinessMixin): if self.n > 0: shifted = (dtindex.to_perioddelta("B") - time).asi8 != 0 - # Integer-array addition is deprecated, so we use - # _time_shift directly roll = np.where(shifted, self.n - 1, self.n) shifted = asper._addsub_int_array(roll, operator.add) else: @@ -2516,7 +2514,7 @@ cdef class Week(SingleConstructorOffset): from .frequencies import get_freq_code # TODO: avoid circular import i8other = dtindex.asi8 - off = (i8other % DAY_NANOS).view("timedelta64") + off = (i8other % DAY_NANOS).view("timedelta64[ns]") base, mult = get_freq_code(self.freqstr) base_period = dtindex.to_period(base) From 94f30a81bce22a393add883df2b5a0048e8e294a Mon Sep 17 00:00:00 2001 From: Brock Date: Wed, 3 Jun 2020 19:31:24 -0700 Subject: [PATCH 4/4] fix _params kludge --- pandas/_libs/tslibs/offsets.pyx | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index b292e40a3b2c1..e8f4208574dbe 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -2459,12 +2459,7 @@ cdef class Week(SingleConstructorOffset): self.n = state.pop("n") self.normalize = state.pop("normalize") self.weekday = state.pop("weekday") - - @property - def _params(self): - # TODO: making this into a property shouldn't be necessary, but otherwise - # we unpickle legacy objects incorrectly - return BaseOffset._params.func(self) + self._cache = state.pop("_cache", {}) def is_anchored(self) -> bool: return self.n == 1 and self.weekday is not None