add_interval

add_interval(index, other)[source]

Add an interval to a continuous interval index.

A continuous interval index has one specific property; none of the intervals overlap. Hence, adding intervals to a continuous interval index has the following behavior:

Adding an interval which does not overlap with the index

The interval is simply added.

Adding an interval which overlaps partially with an interval in the index

The index’ interval is extended.

Adding an interval which overlaps completely with an interval in the index

The interval is ignored.

Parameters:
  • index (IntervalIndex) – The continuous interval index.

  • other (Interval) – The interval to add. Must have the same interval type.

Returns:

The new index after adding the interval.

Return type:

IntervalIndex