Пример #1
0
def path_length(tree):
    '''Get the path length from a sub-tree to the root node'''
    t = tree
    l2 = []
    while t.parent is not None:
        l2.append(mm.segment_length2((t.parent.value, t.value)))
        t = t.parent

    return np.sum(np.sqrt(l2))
Пример #2
0
def test_segment_length2():
    p1 = Point(3.0, 4.0, 5.0, 3.0)
    p2 = Point(4.0, 5.0, 6.0, 3.0)
    dist = mm.segment_length2((p1, p2))
    assert dist == 3
Пример #3
0
def test_segment_length2():
    p1 = Point(3.0, 4.0, 5.0, 3.0, 1)
    p2 = Point(4.0, 5.0, 6.0, 3.0, 1)
    dist = mm.segment_length2((p1, p2))
    nt.eq_(dist, 3)