intervaltree icon indicating copy to clipboard operation
intervaltree copied to clipboard

docs for envelop vs containsi vs in

Open bw2 opened this issue 6 years ago • 2 comments

Thanks for the great library. I was looking for a method to check if an interval tree fully envelops some interval, and I couldn't figure out whether envelop(begin, end), interval_obj in tree (this is fastest, O(1)), or tree.containsi(begin, end, data) was the one to use without testing them in code. It would be great if the README could clarify their behavior.

bw2 avatar Jul 29 '19 04:07 bw2

What I ended up using was

def tree_envelops_interval(t, i):
    return any(ti.contains_interval(i) for ti in interval_tree.overlap(i))

bw2 avatar Jul 29 '19 04:07 bw2