Skip to content

CLN: remove ABCTimedelta #34559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pandas/_libs/index.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ cnp.import_array()
from pandas._libs cimport util

from pandas._libs.tslibs.nattype cimport c_NaT as NaT
from pandas._libs.tslibs.base cimport ABCTimedelta
from pandas._libs.tslibs.period cimport is_period_object
from pandas._libs.tslibs.timestamps cimport _Timestamp
from pandas._libs.tslibs.timedeltas cimport _Timedelta

from pandas._libs.hashtable cimport HashTable

Expand Down Expand Up @@ -471,7 +471,7 @@ cdef class TimedeltaEngine(DatetimeEngine):
return 'm8[ns]'

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

Expand Down
4 changes: 2 additions & 2 deletions pandas/_libs/interval.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ from pandas._libs.tslibs.util cimport (
is_timedelta64_object,
)

from pandas._libs.tslibs.base cimport ABCTimedelta
from pandas._libs.tslibs.timezones cimport tz_compare
from pandas._libs.tslibs.timestamps cimport _Timestamp
from pandas._libs.tslibs.timedeltas cimport _Timedelta

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

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

Expand Down
5 changes: 1 addition & 4 deletions pandas/_libs/tslibs/base.pxd
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
from cpython.datetime cimport datetime, timedelta

cdef class ABCTimedelta(timedelta):
pass
from cpython.datetime cimport datetime


cdef class ABCTimestamp(datetime):
Expand Down
6 changes: 1 addition & 5 deletions pandas/_libs/tslibs/base.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ in order to allow for fast isinstance checks without circular dependency issues.
This is analogous to core.dtypes.generic.
"""

from cpython.datetime cimport datetime, timedelta


cdef class ABCTimedelta(timedelta):
pass
from cpython.datetime cimport datetime


cdef class ABCTimestamp(datetime):
Expand Down
12 changes: 12 additions & 0 deletions pandas/_libs/tslibs/timedeltas.pxd
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
from cpython.datetime cimport timedelta
from numpy cimport int64_t

# Exposed for tslib, not intended for outside use.
cpdef int64_t delta_to_nanoseconds(delta) except? -1
cdef convert_to_timedelta64(object ts, object unit)
cdef bint is_any_td_scalar(object obj)


cdef class _Timedelta(timedelta):
cdef readonly:
int64_t value # nanoseconds
object freq # frequency reference
bint is_populated # are my components populated
int64_t _d, _h, _m, _s, _ms, _us, _ns

cpdef timedelta to_pytimedelta(_Timedelta self)
cpdef bint _has_ns(self)
14 changes: 7 additions & 7 deletions pandas/_libs/tslibs/timedeltas.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ from pandas._libs.tslibs.util cimport (
is_float_object, is_array
)

from pandas._libs.tslibs.base cimport ABCTimedelta, ABCTimestamp
from pandas._libs.tslibs.base cimport ABCTimestamp

from pandas._libs.tslibs.conversion cimport cast_from_unit

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

# higher than np.ndarray and np.matrix
__array_priority__ = 100
Expand Down