Ejemplo n.º 1
0
    def test_point_types(self):
        emptyTree = kdtree.create(dimensions=3)
        point1 = (2, 3, 4)
        point2 = [4, 5, 6]
        Point = collections.namedtuple('Point', 'x y z')
        point3 = Point(5, 3, 2)
        tree = kdtree.create([point1, point2, point3])
        res, dist = tree.search_nn((1, 2, 3))

        self.assertEqual(res, kdtree.KDNode((2, 3, 4)))
Ejemplo n.º 2
0
    def test_invalid_child(self):
        """ Children on wrong subtree invalidate Tree """
        child = kdtree.KDNode((3, 2))
        child.axis = 2
        tree = kdtree.create([(2, 3)])
        tree.left = child
        self.assertFalse(tree.is_valid())

        tree = kdtree.create([(4, 1)])
        tree.right = child
        self.assertFalse(tree.is_valid())