Skip to content

interval.overlaps() mishandles empty intervals #26893

Open
@ghost

Description

The special case where left=right is not checked properly by the constructor, only closed='both' (a point) or closed='neither' (an empty interval) makes sense but '[0,0)' or (0,0] are nonsensical. The overlaps method returns inconsistent results when encountering such Intervals.

import pandas as pd
pd.Interval(0,0,'left')

Update:
Examples (from below):

In [4]:  
   ...: import pandas as pd
   ...: from pandas import Interval
   ...: 
   ...: a=Interval(0,1,'both')
   ...: b=Interval(0,0,'right')
   ...: print(a.overlaps(b))
   ...: b=Interval(0,0,'left')
   ...: print(a.overlaps(b))
True
False

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions