Пример #1
0
 def test_all_same(self):
     # A bit simpler, every point is the same.
     data = np.ones((1000, 3))
     manifold = Manifold(data, 'euclidean').build()
     # There should only ever be one cluster here.
     self.assertEqual(1, len(manifold.layers))
     manifold.build_tree()
     # Even after explicit deepen calls.
     self.assertEqual(1, len(manifold.layers))
     self.assertEqual(
         1, len(manifold.find_clusters(np.asarray([1, 1, 1]), 0.0, -1)))
     # And, we should get all 1000 points back for any of the data.
     self.assertEqual(1000, len(manifold.find_points(data[0], 0.0)))
     return
Пример #2
0
    def test_build_tree(self):
        m = Manifold(self.data, 'euclidean')
        self.assertEqual(1, len(m.layers))

        m.build_tree(criterion.AddLevels(2))
        self.assertEqual(3, len(m.layers))

        # MaxDepth shouldn't do anything in build_tree if we're beyond that depth already.
        m.build_tree(criterion.MaxDepth(1))
        self.assertEqual(3, len(m.layers))

        m.build_tree()
        self.assertEqual(len(self.data), m.layers[-1].cardinality)
        return