def test_1(self): tree = IntervalTree() tree.add(1, 3, 100) tree.add(3, 7, 110) tree.add(2, 5, 120) tree.add(4, 6, 130) print(tree.pretty_print()) print(tree.find(Interval(2, 5))) tree.remove(Interval(2, 5)) print(tree.find(Interval(2, 5))) print(tree.pretty_print()) self.assertEqual(True, True)
def test_error(self): iv = IntervalTree() iv.add(10, 17) iv.add(25, 32) iv.add(15, 22) iv.add(20, 27) print(iv.pretty_print()) print(iv.search(0, 220))
def test_2(self): tree = IntervalTree() tree.add(1, 3, 1.0) tree.add(2, 3, 2.0) tree.add(3, 4, 3.0) tree.add(3, 5, 4.0) tree.add(4, 5, 5.0) tree.add(5, 6, 5.0) tree.add(2, 6, 6.0) print(tree.pretty_print()) self.assertEqual(len(tree.search(4, 4)), 3) self.assertEqual(len(tree.search(3, 3)), 3) self.assertEqual(len(tree.search(4, 6)), 4)
def test_3(self): tree = IntervalTree() tree.add(1, 1, 1.0) print(tree.pretty_print()) print((tree.search(1, 3)))
from quicksectx import IntervalTree, Interval import unittest tree = IntervalTree() tree.add(0, 3, 100) tree.add(5, 8, 110) tree.add(6, 10, 120) tree.add(8, 9, 130) tree.add(15, 23, 140) tree.add(19, 20, 150) tree.add(17, 19, 160) tree.add(26, 26, 160) tree.add(25, 30, 160) tree.add(16, 21, 160) print(tree.search(3, 15)) print(tree.pretty_print()) print('\n\n---\n\n\n') tree = IntervalTree() tree.add(0, 3, 100) tree.add(5, 8, 110) tree.add(6, 10, 120) tree.add(8, 9, 130) tree.add(15, 23, 140) tree.add(16, 21, 160) tree.add(17, 19, 160) tree.add(19, 20, 150) tree.add(25, 30, 160) tree.add(26, 26, 160) tree.add(27, 28, 160) tree.add(27, 28, 160) tree.add(27, 28, 160) print(tree.pretty_print())