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 1 commit
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("ABCPeriod", "_typ", ("interval", ))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first argument should be "ABCInterval" instead of "ABCPeriod", right? Or am I missing something?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jschendel : I don't believe you are.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jbrockmendel : Do we need any tests for this new ABCType ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yah typo, will fix, good catch.



class _ABCGeneric(type):
Expand Down