Skip to content

Commit 88db451

Browse files
authored
CLN: remove ABCTimedelta (#34559)
1 parent 2891970 commit 88db451

File tree

6 files changed

+25
-20
lines changed

6 files changed

+25
-20
lines changed

pandas/_libs/index.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ cnp.import_array()
2222
from pandas._libs cimport util
2323

2424
from pandas._libs.tslibs.nattype cimport c_NaT as NaT
25-
from pandas._libs.tslibs.base cimport ABCTimedelta
2625
from pandas._libs.tslibs.period cimport is_period_object
2726
from pandas._libs.tslibs.timestamps cimport _Timestamp
27+
from pandas._libs.tslibs.timedeltas cimport _Timedelta
2828

2929
from pandas._libs.hashtable cimport HashTable
3030

@@ -471,7 +471,7 @@ cdef class TimedeltaEngine(DatetimeEngine):
471471
return 'm8[ns]'
472472

473473
cdef int64_t _unbox_scalar(self, scalar) except? -1:
474-
if not (isinstance(scalar, ABCTimedelta) or scalar is NaT):
474+
if not (isinstance(scalar, _Timedelta) or scalar is NaT):
475475
raise TypeError(scalar)
476476
return scalar.value
477477

pandas/_libs/interval.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ from pandas._libs.tslibs.util cimport (
4242
is_timedelta64_object,
4343
)
4444

45-
from pandas._libs.tslibs.base cimport ABCTimedelta
4645
from pandas._libs.tslibs.timezones cimport tz_compare
4746
from pandas._libs.tslibs.timestamps cimport _Timestamp
47+
from pandas._libs.tslibs.timedeltas cimport _Timedelta
4848

4949
_VALID_CLOSED = frozenset(['left', 'right', 'both', 'neither'])
5050

@@ -340,7 +340,7 @@ cdef class Interval(IntervalMixin):
340340
def _validate_endpoint(self, endpoint):
341341
# GH 23013
342342
if not (is_integer_object(endpoint) or is_float_object(endpoint) or
343-
isinstance(endpoint, (_Timestamp, ABCTimedelta))):
343+
isinstance(endpoint, (_Timestamp, _Timedelta))):
344344
raise ValueError("Only numeric, Timestamp and Timedelta endpoints "
345345
"are allowed when constructing an Interval.")
346346

pandas/_libs/tslibs/base.pxd

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
from cpython.datetime cimport datetime, timedelta
2-
3-
cdef class ABCTimedelta(timedelta):
4-
pass
1+
from cpython.datetime cimport datetime
52

63

74
cdef class ABCTimestamp(datetime):

pandas/_libs/tslibs/base.pyx

+1-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ in order to allow for fast isinstance checks without circular dependency issues.
55
This is analogous to core.dtypes.generic.
66
"""
77

8-
from cpython.datetime cimport datetime, timedelta
9-
10-
11-
cdef class ABCTimedelta(timedelta):
12-
pass
8+
from cpython.datetime cimport datetime
139

1410

1511
cdef class ABCTimestamp(datetime):

pandas/_libs/tslibs/timedeltas.pxd

+12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1+
from cpython.datetime cimport timedelta
12
from numpy cimport int64_t
23

34
# Exposed for tslib, not intended for outside use.
45
cpdef int64_t delta_to_nanoseconds(delta) except? -1
56
cdef convert_to_timedelta64(object ts, object unit)
67
cdef bint is_any_td_scalar(object obj)
8+
9+
10+
cdef class _Timedelta(timedelta):
11+
cdef readonly:
12+
int64_t value # nanoseconds
13+
object freq # frequency reference
14+
bint is_populated # are my components populated
15+
int64_t _d, _h, _m, _s, _ms, _us, _ns
16+
17+
cpdef timedelta to_pytimedelta(_Timedelta self)
18+
cpdef bint _has_ns(self)

pandas/_libs/tslibs/timedeltas.pyx

+7-7
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ from pandas._libs.tslibs.util cimport (
2121
is_float_object, is_array
2222
)
2323

24-
from pandas._libs.tslibs.base cimport ABCTimedelta, ABCTimestamp
24+
from pandas._libs.tslibs.base cimport ABCTimestamp
2525

2626
from pandas._libs.tslibs.conversion cimport cast_from_unit
2727

@@ -675,12 +675,12 @@ cdef _to_py_int_float(v):
675675
# timedeltas that we need to do object instantiation in python. This will
676676
# serve as a C extension type that shadows the Python class, where we do any
677677
# heavy lifting.
678-
cdef class _Timedelta(ABCTimedelta):
679-
cdef readonly:
680-
int64_t value # nanoseconds
681-
object freq # frequency reference
682-
bint is_populated # are my components populated
683-
int64_t _d, _h, _m, _s, _ms, _us, _ns
678+
cdef class _Timedelta(timedelta):
679+
# cdef readonly:
680+
# int64_t value # nanoseconds
681+
# object freq # frequency reference
682+
# bint is_populated # are my components populated
683+
# int64_t _d, _h, _m, _s, _ms, _us, _ns
684684

685685
# higher than np.ndarray and np.matrix
686686
__array_priority__ = 100

0 commit comments

Comments
 (0)