Skip to content

Commit a50ea1c

Browse files
authoredOct 14, 2022
REF: _as_reso->_as_creso (#49098)
1 parent 81b5e74 commit a50ea1c

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed
 

‎pandas/_libs/index.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,8 @@ cdef class DatetimeEngine(Int64Engine):
506506
return scalar.value
507507
else:
508508
# Note: caller is responsible for catching potential ValueError
509-
# from _as_reso
510-
return (<_Timestamp>scalar)._as_reso(self.reso, round_ok=False).value
509+
# from _as_creso
510+
return (<_Timestamp>scalar)._as_creso(self.reso, round_ok=False).value
511511
raise TypeError(scalar)
512512

513513
def __contains__(self, val: object) -> bool:
@@ -574,8 +574,8 @@ cdef class TimedeltaEngine(DatetimeEngine):
574574
return scalar.value
575575
else:
576576
# Note: caller is responsible for catching potential ValueError
577-
# from _as_reso
578-
return (<_Timedelta>scalar)._as_reso(self.reso, round_ok=False).value
577+
# from _as_creso
578+
return (<_Timedelta>scalar)._as_creso(self.reso, round_ok=False).value
579579
raise TypeError(scalar)
580580

581581

‎pandas/_libs/tslibs/offsets.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,7 +1325,7 @@ cdef class RelativeDeltaOffset(BaseOffset):
13251325
weeks = kwds.get("weeks", 0) * self.n
13261326
if weeks:
13271327
delta = Timedelta(days=7 * weeks)
1328-
td = (<_Timedelta>delta)._as_reso(reso)
1328+
td = (<_Timedelta>delta)._as_creso(reso)
13291329
dt64other = dt64other + td
13301330

13311331
timedelta_kwds = {
@@ -1335,7 +1335,7 @@ cdef class RelativeDeltaOffset(BaseOffset):
13351335
}
13361336
if timedelta_kwds:
13371337
delta = Timedelta(**timedelta_kwds)
1338-
td = (<_Timedelta>delta)._as_reso(reso)
1338+
td = (<_Timedelta>delta)._as_creso(reso)
13391339
dt64other = dt64other + (self.n * td)
13401340
return dt64other
13411341
elif not self._use_relativedelta and hasattr(self, "_offset"):
@@ -1346,7 +1346,7 @@ cdef class RelativeDeltaOffset(BaseOffset):
13461346
delta = Timedelta((self._offset + rem_nano) * self.n)
13471347
else:
13481348
delta = Timedelta(self._offset * self.n)
1349-
td = (<_Timedelta>delta)._as_reso(reso)
1349+
td = (<_Timedelta>delta)._as_creso(reso)
13501350
return dt64other + td
13511351
else:
13521352
# relativedelta with other keywords
@@ -3394,7 +3394,7 @@ cdef class FY5253Quarter(FY5253Mixin):
33943394
for qlen in qtr_lens:
33953395
if qlen * 7 <= tdelta.days:
33963396
num_qtrs += 1
3397-
tdelta -= (<_Timedelta>Timedelta(days=qlen * 7))._as_reso(norm._reso)
3397+
tdelta -= (<_Timedelta>Timedelta(days=qlen * 7))._as_creso(norm._reso)
33983398
else:
33993399
break
34003400
else:

‎pandas/_libs/tslibs/timedeltas.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ cdef class _Timedelta(timedelta):
2424
cdef bint _has_ns(self)
2525
cdef _ensure_components(_Timedelta self)
2626
cdef inline bint _compare_mismatched_resos(self, _Timedelta other, op)
27-
cdef _Timedelta _as_reso(self, NPY_DATETIMEUNIT reso, bint round_ok=*)
27+
cdef _Timedelta _as_creso(self, NPY_DATETIMEUNIT reso, bint round_ok=*)
2828
cpdef _maybe_cast_to_matching_resos(self, _Timedelta other)

‎pandas/_libs/tslibs/timedeltas.pyx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -793,9 +793,9 @@ def _binary_op_method_timedeltalike(op, name):
793793
# Matching numpy, we cast to the higher resolution. Unlike numpy,
794794
# we raise instead of silently overflowing during this casting.
795795
if self._reso < other._reso:
796-
self = (<_Timedelta>self)._as_reso(other._reso, round_ok=True)
796+
self = (<_Timedelta>self)._as_creso(other._reso, round_ok=True)
797797
elif self._reso > other._reso:
798-
other = (<_Timedelta>other)._as_reso(self._reso, round_ok=True)
798+
other = (<_Timedelta>other)._as_creso(self._reso, round_ok=True)
799799

800800
res = op(self.value, other.value)
801801
if res == NPY_NAT:
@@ -1541,10 +1541,10 @@ cdef class _Timedelta(timedelta):
15411541
def _as_unit(self, str unit, bint round_ok=True):
15421542
dtype = np.dtype(f"m8[{unit}]")
15431543
reso = get_unit_from_dtype(dtype)
1544-
return self._as_reso(reso, round_ok=round_ok)
1544+
return self._as_creso(reso, round_ok=round_ok)
15451545

15461546
@cython.cdivision(False)
1547-
cdef _Timedelta _as_reso(self, NPY_DATETIMEUNIT reso, bint round_ok=True):
1547+
cdef _Timedelta _as_creso(self, NPY_DATETIMEUNIT reso, bint round_ok=True):
15481548
cdef:
15491549
int64_t value
15501550

@@ -1566,9 +1566,9 @@ cdef class _Timedelta(timedelta):
15661566
If _resos do not match, cast to the higher resolution, raising on overflow.
15671567
"""
15681568
if self._reso > other._reso:
1569-
other = other._as_reso(self._reso)
1569+
other = other._as_creso(self._reso)
15701570
elif self._reso < other._reso:
1571-
self = self._as_reso(other._reso)
1571+
self = self._as_creso(other._reso)
15721572
return self, other
15731573

15741574

‎pandas/_libs/tslibs/timestamps.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ cdef class _Timestamp(ABCTimestamp):
3737
cpdef void _set_freq(self, freq)
3838
cdef _warn_on_field_deprecation(_Timestamp self, freq, str field)
3939
cdef bint _compare_mismatched_resos(_Timestamp self, _Timestamp other, int op)
40-
cdef _Timestamp _as_reso(_Timestamp self, NPY_DATETIMEUNIT reso, bint round_ok=*)
40+
cdef _Timestamp _as_creso(_Timestamp self, NPY_DATETIMEUNIT reso, bint round_ok=*)

‎pandas/_libs/tslibs/timestamps.pyx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,9 @@ cdef class _Timestamp(ABCTimestamp):
436436
# Matching numpy, we cast to the higher resolution. Unlike numpy,
437437
# we raise instead of silently overflowing during this casting.
438438
if self._reso < other._reso:
439-
self = (<_Timestamp>self)._as_reso(other._reso, round_ok=True)
439+
self = (<_Timestamp>self)._as_creso(other._reso, round_ok=True)
440440
elif self._reso > other._reso:
441-
other = (<_Timedelta>other)._as_reso(self._reso, round_ok=True)
441+
other = (<_Timedelta>other)._as_creso(self._reso, round_ok=True)
442442

443443
nanos = other.value
444444

@@ -525,9 +525,9 @@ cdef class _Timestamp(ABCTimestamp):
525525
# Matching numpy, we cast to the higher resolution. Unlike numpy,
526526
# we raise instead of silently overflowing during this casting.
527527
if self._reso < other._reso:
528-
self = (<_Timestamp>self)._as_reso(other._reso, round_ok=False)
528+
self = (<_Timestamp>self)._as_creso(other._reso, round_ok=False)
529529
elif self._reso > other._reso:
530-
other = (<_Timestamp>other)._as_reso(self._reso, round_ok=False)
530+
other = (<_Timestamp>other)._as_creso(self._reso, round_ok=False)
531531

532532
# scalar Timestamp/datetime - Timestamp/datetime -> yields a
533533
# Timedelta
@@ -1062,7 +1062,7 @@ cdef class _Timestamp(ABCTimestamp):
10621062
# Conversion Methods
10631063

10641064
@cython.cdivision(False)
1065-
cdef _Timestamp _as_reso(self, NPY_DATETIMEUNIT reso, bint round_ok=True):
1065+
cdef _Timestamp _as_creso(self, NPY_DATETIMEUNIT reso, bint round_ok=True):
10661066
cdef:
10671067
int64_t value
10681068

@@ -1076,7 +1076,7 @@ cdef class _Timestamp(ABCTimestamp):
10761076
dtype = np.dtype(f"M8[{unit}]")
10771077
reso = get_unit_from_dtype(dtype)
10781078
try:
1079-
return self._as_reso(reso, round_ok=round_ok)
1079+
return self._as_creso(reso, round_ok=round_ok)
10801080
except OverflowError as err:
10811081
raise OutOfBoundsDatetime(
10821082
f"Cannot cast {self} to unit='{unit}' without overflow."

0 commit comments

Comments
 (0)
Please sign in to comment.