jeetsukumaran / DendroPy

A Python library for phylogenetic scripting, simulation, data processing and manipulation.
https://pypi.org/project/DendroPy/.
BSD 3-Clause "New" or "Revised" License
207 stars 62 forks source link

Bug in dendropy.model.coalescent.contained_coalescent_tree #115

Closed joaks1 closed 5 years ago

joaks1 commented 5 years ago

On Line 516 of coalescent.py, I think pop_size=default_pop_size should be pop_size=pop_size. Here's some context (Lines 509-518):

        if edge_pop_size_attr and hasattr(edge, edge_pop_size_attr):
            pop_size = getattr(edge, edge_pop_size_attr)
        else:
            pop_size = default_pop_size
        if edge.head_node.parent_node is None:
            if len(pop_node_genes[edge.head_node]) > 1:
                final = coalesce_nodes(nodes=pop_node_genes[edge.head_node],
                                            pop_size=default_pop_size,
                                            period=None,
                                            rng=rng)

Currently, the default population size is always used for the root edge, even if a different size is given as an attribute of the root edge.

joaks1 commented 5 years ago

I created pull request #116 that fixes this bug.

jeetsukumaran commented 5 years ago

Thanks, Jamie. Good catch.