MCPcopy Create free account
hub / github.com/chaimleib/intervaltree / intersection

Method intersection

intervaltree/intervaltree.py:426–436  ·  view source on GitHub ↗

Returns a new tree of all intervals common to both self and other.

(self, other)

Source from the content-addressed store, hash-verified

424 return IntervalTree(set(self).union(other))
425
426 def intersection(self, other):
427 """
428 Returns a new tree of all intervals common to both self and
429 other.
430 """
431 ivs = set()
432 shorter, longer = sorted([self, other], key=len)
433 for iv in shorter:
434 if iv in longer:
435 ivs.add(iv)
436 return IntervalTree(ivs)
437
438 def intersection_update(self, other):
439 """

Callers 1

test_intersectionFunction · 0.95

Calls 2

IntervalTreeClass · 0.85
addMethod · 0.45

Tested by 1

test_intersectionFunction · 0.76