def test_five(self): pts = [(20, 10), (90, 50), (60, 80), (70, 30), (40, 100)] tree = generate(pts) self.assertEqual(60, tree.root.point[X]) # on X-coordinate self.assertEqual(20, tree.root.below.point[X]) self.assertEqual(70, tree.root.above.point[X])
def test_three(self): pts = [(20, 10), (90, 50), (60, 80)] tree = generate(pts) self.assertEqual(60, tree.root.point[X]) # on X-coordinate self.assertEqual(20, tree.root.below.point[X]) self.assertEqual(90, tree.root.above.point[X]) # regions self.assertEqual(60, tree.root.below.region.x_max)
def rebalance(self): """Rebalance points in tree""" points = [p for p in self.tree] if points: self.tree = kd_factory.generate(points) self.paint()