def testiscovered(self): T = SNT(3, 1, 1) metric = Euclidean() a = Node(Point([0, 0], metric), 2) b = Node(Point([0, 12], metric), 1) c = Node(b.point, 0) a.addch(b) b.addch(c) self.assertTrue(T.iscovered(c)) self.assertEqual(metric.counter, 0) self.assertFalse(T.iscovered(b)) T.cc = 2 self.assertTrue(T.iscovered(b))
def testconstructwithverification(self): points = [ Point([x, 0, 1], Euclidean()) for x in [8, 1, 2, 32, 64, 81, 80, 160] ] T = SNT(4, 1, 1, 4) T.construct(points, PL) ver = SNTVerify(T, points) ver.populate() self.assertTrue(ver.relativescorrect()) self.assertTrue(ver.issemicompressed()) self.assertTrue(ver.islocalnettree()) self.assertFalse(ver.isglobalnettree()) T.cc = 4 / 3 T.cp = 1 / 6 self.assertTrue(ver.isglobalnettree()) points = [Point([x], Euclidean()) for x in [7, 44, 30, 24, 76]] T = SNT(5, 1, 1) T.construct(points, PL) ver = SNTVerify(T, points) ver.populate() self.assertTrue(ver.relativescorrect()) self.assertTrue(ver.issemicompressed()) self.assertTrue(ver.islocalnettree()) T.cc = 5 / 4 T.cp = 1 / 4 self.assertTrue(ver.isglobalnettree()) points = [Point([x], Euclidean()) for x in [25, 20, 54, 30, 40, 0]] T = SNT(5, 1, 1) T.construct(points, PL) ver = SNTVerify(T, points) ver.populate() self.assertTrue(ver.relativescorrect()) self.assertTrue(ver.issemicompressed()) self.assertTrue(ver.islocalnettree()) T.cc = 5 / 4 T.cp = 1 / 4 self.assertTrue(ver.isglobalnettree()) points = [ Point([x], Euclidean()) for x in [-55, 93, -90, -14, -13, -12] ] T = SNT(7, 1, 1) T.construct(points, PL) ver = SNTVerify(T, points) ver.populate() self.assertTrue(ver.relativescorrect()) self.assertTrue(ver.islocalnettree()) self.assertTrue(ver.issemicompressed()) metric = Euclidean() points = [ Point([random.randint(-10000, 10000) for _ in range(2)], metric) for _ in range(200) ] tmp = list() for p in points: if p in tmp: print('duplicate:', p) else: tmp.append(p) points = tmp tau = 7 T = SNT(tau, 1, 1) T.construct(points, PL) ver = SNTVerify(T, points) ver.populate() self.assertTrue(ver.relativescorrect()) self.assertTrue(ver.islocalnettree()) self.assertTrue(ver.issemicompressed()) T.cc = tau / (tau - 1) T.cp = (tau - 3) / (2 * (tau - 1)) self.assertTrue(ver.isglobalnettree())