Ejemplo n.º 1
0
    def test_mean_vertex_weights(self):
        tree, altitudes = TestAttributes.get_test_tree()

        leaf_data = np.asarray((0, 1, 2, 3, 4, 5, 6, 7, 8), dtype=np.float64)
        ref_attribute = np.asarray((0, 1, 2, 3, 4, 5, 6, 7, 8, 1. / 2, 7. / 2,
                                    7. / 2, 13. / 2, 7., 2., 29. / 7, 4.))

        attribute = hg.attribute_mean_vertex_weights(tree,
                                                     vertex_weights=leaf_data)
        self.assertTrue(np.allclose(ref_attribute, attribute))
Ejemplo n.º 2
0
    def test_mean_vertex_weights_vectorial(self):
        tree, altitudes = TestAttributes.get_test_tree()

        leaf_data = np.asarray(((0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5),
                                (6, 6), (7, 7), (8, 8)),
                               dtype=np.float64)
        ref_attribute = np.asarray(
            ((0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7),
             (8, 8), (1. / 2, 1. / 2), (7. / 2, 7. / 2), (7. / 2, 7. / 2),
             (13. / 2, 13. / 2), (7., 7.), (2., 2.), (29. / 7, 29. / 7), (4.,
                                                                          4.)))

        attribute = hg.attribute_mean_vertex_weights(tree,
                                                     vertex_weights=leaf_data)
        self.assertTrue(np.allclose(ref_attribute, attribute))