intervaltree icon indicating copy to clipboard operation
intervaltree copied to clipboard

Include and exclude interval ends

Open satyrmipt opened this issue 1 year ago • 3 comments

Looks like interval ends are always excluded. May i control this behaviour? See no such parameters in Interval docstring

it.Interval(1, 2).overlaps(2,3), it.Interval(1, 2).overlaps(1,1), it.Interval(1, 2).overlaps(2,2)
# (False, False, False)

satyrmipt avatar Aug 30 '24 09:08 satyrmipt

Not quite. In an interval, the begin is part of the interval, but not the end (like slice notation for a string). A zero-length interval is the null interval and intersects with nothing.

chaimleib avatar Aug 30 '24 18:08 chaimleib

Oh, I thought about it in terms of sets, and mathematics allows us to have set of one element. Like string of one letter.

satyrmipt avatar Aug 30 '24 18:08 satyrmipt

Pulling one letter out of a string would be like "hello"[1:2], so Interval(1,2) has length 1.

Mathematically, IntervalTree uses half-open intervals.

chaimleib avatar Aug 30 '24 18:08 chaimleib