Skip to content

Commit e865b77

Browse files
jbrockmendeljreback
authored andcommitted
implement ABCInterval (#19367)
1 parent 83e95e0 commit e865b77

File tree

5 files changed

+5
-2
lines changed

5 files changed

+5
-2
lines changed

pandas/_libs/interval.pyx

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ cdef class Interval(IntervalMixin):
109109
cut, qcut : Convert arrays of continuous data into Categoricals/Series of
110110
Interval.
111111
"""
112+
_typ = "interval"
112113

113114
cdef readonly object left
114115
"""Left bound for the interval"""

pandas/_libs/lib.pyx

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ from cpython.datetime cimport (PyDateTime_Check, PyDate_Check,
4141
PyDateTime_IMPORT
4242

4343
from tslib import NaT, Timestamp, Timedelta, array_to_datetime
44-
from interval import Interval
4544
from missing cimport checknull
4645

4746

pandas/_libs/src/inference.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ cpdef bint is_decimal(object obj):
3737

3838

3939
cpdef bint is_interval(object obj):
40-
return isinstance(obj, Interval)
40+
return getattr(obj, '_typ', '_typ') == 'interval'
4141

4242

4343
cpdef bint is_period(object val):

pandas/core/dtypes/generic.py

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def _check(cls, inst):
5454
ABCPeriod = create_pandas_abc_type("ABCPeriod", "_typ", ("period", ))
5555
ABCDateOffset = create_pandas_abc_type("ABCDateOffset", "_typ",
5656
("dateoffset",))
57+
ABCInterval = create_pandas_abc_type("ABCInterval", "_typ", ("interval", ))
5758

5859

5960
class _ABCGeneric(type):

pandas/tests/dtypes/test_generic.py

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ def test_abc_types(self):
4545
gt.ABCDateOffset)
4646
assert not isinstance(pd.Period('2012', freq='A-DEC'),
4747
gt.ABCDateOffset)
48+
assert isinstance(pd.Interval(0, 1.5), gt.ABCInterval)
49+
assert not isinstance(pd.Period('2012', freq='A-DEC'), gt.ABCInterval)
4850

4951

5052
def test_setattr_warnings():

0 commit comments

Comments
 (0)