def testCTwith2points(self): # Make some points p = Point([3,4]) q = Point([1,1]) q.updatepred(p) # Make a covertree ct = CoverTree() ct.insert(p) ct.insert(q) r = ct.root # The root should be p self.assertEqual(r.point, p) # The root should have 2 children self.assertEqual(len(r.ch), 2) # The children should have points 1 and 2 self.assertEqual({r.ch[0].point, r.ch[1].point}, {p,q}) # Updated leaves points to new p self.assertEqual(ct.leaves[p].level, ct.leaves[q].level)
def test_updatepred(self): p = Point([0]) p.updatepred(Point([100])) self.assertEqual(p.dis, 100**2) p.updatepred(Point([101])) self.assertEqual(p.dis, 100**2) p.updatepred(Point([99])) self.assertEqual(p.dis, 99**2)