Ejemplo n.º 1
0
 def test_split_bbox(self):
     pts = [(x, y) for x in range(5) for y in range(5)]
     node = Node(pts, (0, 0, 4, 4), True)
     parent = split(node)
     self.assertEqual(parent.children[0].bbox, (0, 0, 2, 2))
     self.assertEqual(parent.children[1].bbox, (2, 0, 4, 2))
     self.assertEqual(parent.children[2].bbox, (0, 2, 2, 4))
     self.assertEqual(parent.children[3].bbox, (2, 2, 4, 4))
     return
Ejemplo n.º 2
0
 def test_addpt_full(self):
     pts = [(x, y) for x in range(5) for y in range(5)]
     node = Node(pts, (0, 0, 4.1, 4.1), True)
     (node, _) = addpt(node, (2.5, 2.5), 1, 25, 100)
     self.assertEqual(node.children[0].children,
                      [(x, y) for x in range(3) for y in range(3)])
     self.assertEqual(node.children[1].children,
                      [(x, y) for x in range(3, 5) for y in range(3)])
     self.assertEqual(node.children[2].children,
                      [(x, y) for x in range(3) for y in range(3, 5)])
     self.assertEqual(node.children[3].children,
                      [(x, y) for x in range(3, 5)
                       for y in range(3, 5)] + [(2.5, 2.5)])
Ejemplo n.º 3
0
 def test_split(self):
     pts = [(x, y) for x in range(5) for y in range(5)]
     node = Node(pts, (0, 0, 4.1, 4.1), True)
     parent = split(node)
     self.assertEqual(parent.children[0].children,
                      [(x, y) for x in range(3) for y in range(3)])
     self.assertEqual(parent.children[1].children,
                      [(x, y) for x in range(3, 5) for y in range(3)])
     self.assertEqual(parent.children[2].children,
                      [(x, y) for x in range(3) for y in range(3, 5)])
     self.assertEqual(parent.children[3].children,
                      [(x, y) for x in range(3, 5) for y in range(3, 5)])
     return
Ejemplo n.º 4
0
 def test_querypt_hash(self):
     pts = [(x**0.5, 0.5 * y**0.875) for x in range(50) for y in range(50)]
     node = Node([], (0, 0, 7.5, 16), True)
     for pt in pts:
         node, _ = addpt(node, pt, 1, 20, 200)
     testpts = [(x**0.5, 0.5 * y**0.875)
                for (x, y) in zip((3, 12, 44, 23, 36), (46, 42, 28, 2, 13))]
     shouldbetrue = [querypt_hash(node, testpt) for testpt in testpts]
     testpts = [(x**0.5, 0.5 * y**0.875)
                for (x,
                     y) in zip((73, 12, 54, 23, 63), (46, 72, 28, 82, 13))]
     shouldbefalse = [querypt_hash(node, testpt) for testpt in testpts]
     self.assertTrue(False not in shouldbetrue)
     self.assertTrue(True not in shouldbefalse)
     return
Ejemplo n.º 5
0
 def test_querypt_big(self):
     pts = [(x**0.5, 0.05 * y**0.875) for x in range(100)
            for y in range(100)]
     node = Node([], (0, 0, 32, 22), True)
     for pt in pts:
         node, _ = addpt(node, pt, 1, 20, 200)
     testpts = [(x**0.5, 0.05 * y**0.875)
                for (x, y) in zip((3, 12, 44, 23, 36), (46, 42, 28, 2, 13))]
     shouldbetrue = [querypt_recursion(node, testpt) for testpt in testpts]
     testpts = [
         (x**0.5, 0.05 * y**0.875)
         for (x,
              y) in zip((730, 128, 540, 231, 630), (46, 720, 28, 820, 13))
     ]
     shouldbefalse = [querypt_recursion(node, testpt) for testpt in testpts]
     self.assertTrue(False not in shouldbetrue)
     self.assertTrue(True not in shouldbefalse)
     return
Ejemplo n.º 6
0
 def test_addpt_leaf(self):
     node = Node([], (0, 0, 1, 1), True)
     node, _ = addpt(node, (0.5, 0.5), 1, 20, 100)
     self.assertEqual(node.children, [(0.5, 0.5)])
     return