Skip to content

Commit 9100a40

Browse files
committed
operations.pyx: Better document robinson_foulds().
1 parent ae7dd5f commit 9100a40

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

ete4/core/operations.pyx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -824,9 +824,16 @@ def get_distance_fn(topological, asserted=True):
824824
def robinson_foulds(t1, t2, prop='name', normalized=False, strict=False):
825825
"""Return the Robinson-Foulds distance between trees t1 and t2.
826826
827-
The distance is A + B, where
828-
A: number of partitions implied by the 1st tree but not the 2nd
829-
B: number of partitions implied by the 2nd tree but not the 1st
827+
The distance is A + B, where:
828+
829+
- A: number of partitions implied by t1 but not t2
830+
- B: number of partitions implied by t2 but not t1
831+
832+
Every node implies a partition (the leaves that it has at each side).
833+
834+
:param prop: Property of the leaves used to identify them in partitions.
835+
:param normalized: If True, divide by the maximum possible distance.
836+
:param strict: If True, check that t1 and t2 have unique and same leaves.
830837
"""
831838
common_vals = get_common_values(t1, t2, prop, strict)
832839

@@ -850,8 +857,8 @@ def get_common_values(t1, t2, prop='name', strict=False):
850857
851858
If strict, raise AssertionError if t1 and t2 don't share leaves.
852859
"""
853-
vals1 = set(leaf.props.get(prop) for leaf in t1) # can be names
854-
vals2 = set(leaf.props.get(prop) for leaf in t2)
860+
vals1 = set(leaf.props.get(prop) for leaf in t1.leaves()) # can be names
861+
vals2 = set(leaf.props.get(prop) for leaf in t2.leaves())
855862
common_vals = vals1 & vals2 # common leaf values of property prop
856863

857864
assert not strict or (

0 commit comments

Comments
 (0)