Skip to content

implement ABCInterval #19367

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 2 commits into from
Jan 25, 2018
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
1 change: 1 addition & 0 deletions pandas/_libs/interval.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ cdef class Interval(IntervalMixin):
cut, qcut : Convert arrays of continuous data into Categoricals/Series of
Interval.
"""
_typ = "interval"

cdef readonly object left
"""Left bound for the interval"""
Expand Down
1 change: 0 additions & 1 deletion pandas/_libs/lib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ PyDateTime_IMPORT
from tslibs.np_datetime cimport get_timedelta64_value, get_datetime64_value

from tslib import NaT, Timestamp, Timedelta, array_to_datetime
from interval import Interval
from missing cimport checknull


Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/src/inference.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ cpdef bint is_decimal(object obj):


cpdef bint is_interval(object obj):
return isinstance(obj, Interval)
return getattr(obj, '_typ', '_typ') == 'interval'


cpdef bint is_period(object val):
Expand Down
1 change: 1 addition & 0 deletions pandas/core/dtypes/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def _check(cls, inst):
ABCPeriod = create_pandas_abc_type("ABCPeriod", "_typ", ("period", ))
ABCDateOffset = create_pandas_abc_type("ABCDateOffset", "_typ",
("dateoffset",))
ABCInterval = create_pandas_abc_type("ABCInterval", "_typ", ("interval", ))


class _ABCGeneric(type):
Expand Down
2 changes: 2 additions & 0 deletions pandas/tests/dtypes/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def test_abc_types(self):
gt.ABCDateOffset)
assert not isinstance(pd.Period('2012', freq='A-DEC'),
gt.ABCDateOffset)
assert isinstance(pd.Interval(0, 1.5), gt.ABCInterval)
assert not isinstance(pd.Period('2012', freq='A-DEC'), gt.ABCInterval)


def test_setattr_warnings():
Expand Down