Skip to content

Commit 8944b71

Browse files
authored
CLN: address FIXMEs in liboffsets (#34566)
1 parent 2d797f6 commit 8944b71

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

pandas/_libs/tslibs/offsets.pxd

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cdef bint is_offset_object(object obj)
55
cdef bint is_tick_object(object obj)
66

77
cdef class BaseOffset:
8-
cdef readonly:
9-
int64_t n
10-
bint normalize
11-
dict _cache
8+
cdef readonly:
9+
int64_t n
10+
bint normalize
11+
dict _cache

pandas/_libs/tslibs/offsets.pyx

+3-14
Original file line numberDiff line numberDiff line change
@@ -1293,11 +1293,7 @@ cdef class BusinessDay(BusinessMixin):
12931293
self._offset = state.pop("_offset")
12941294
elif "offset" in state:
12951295
self._offset = state.pop("offset")
1296-
1297-
@property
1298-
def _params(self):
1299-
# FIXME: using cache_readonly breaks a pytables test
1300-
return BaseOffset._params.func(self)
1296+
self._cache = state.pop("_cache", {})
13011297

13021298
def _offset_str(self) -> str:
13031299
def get_str(td):
@@ -1384,8 +1380,6 @@ cdef class BusinessDay(BusinessMixin):
13841380
if self.n > 0:
13851381
shifted = (dtindex.to_perioddelta("B") - time).asi8 != 0
13861382

1387-
# Integer-array addition is deprecated, so we use
1388-
# _time_shift directly
13891383
roll = np.where(shifted, self.n - 1, self.n)
13901384
shifted = asper._addsub_int_array(roll, operator.add)
13911385
else:
@@ -2483,12 +2477,7 @@ cdef class Week(SingleConstructorOffset):
24832477
self.n = state.pop("n")
24842478
self.normalize = state.pop("normalize")
24852479
self.weekday = state.pop("weekday")
2486-
2487-
@property
2488-
def _params(self):
2489-
# TODO: making this into a property shouldn't be necessary, but otherwise
2490-
# we unpickle legacy objects incorrectly
2491-
return BaseOffset._params.func(self)
2480+
self._cache = state.pop("_cache", {})
24922481

24932482
def is_anchored(self) -> bool:
24942483
return self.n == 1 and self.weekday is not None
@@ -2537,7 +2526,7 @@ cdef class Week(SingleConstructorOffset):
25372526
from .frequencies import get_freq_code # TODO: avoid circular import
25382527

25392528
i8other = dtindex.asi8
2540-
off = (i8other % DAY_NANOS).view("timedelta64")
2529+
off = (i8other % DAY_NANOS).view("timedelta64[ns]")
25412530

25422531
base, mult = get_freq_code(self.freqstr)
25432532
base_period = dtindex.to_period(base)

0 commit comments

Comments
 (0)