Skip to content

Commit a5979f0

Browse files
YapengLangrmcar17
authored andcommitted
ENH: store model name in tree.params, fixes #354
1 parent f7c2ade commit a5979f0

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

src/piqtree/iqtree/_tree.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def _process_tree_yaml(
7777
_rename_iq_tree(tree, names)
7878

7979
tree.name_unnamed_nodes()
80+
tree.params["model"] = str(model)
8081

8182
return tree
8283

tests/test_iqtree/test_build_tree.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def check_build_tree_model(
3434
assert expected.same_topology(got.unrooted())
3535
# Check if branch lengths exist
3636
assert all(v.length is not None for v in got.get_edge_vector(include_root=False))
37+
assert got.params["model"] == str(model)
3738

3839

3940
def check_build_tree(

tests/test_iqtree/test_fit_tree.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
from piqtree.model import Model, StandardDnaModel
1212

1313

14+
def check_model_name(got: PhyloNode, expected: str) -> None:
15+
got_model = cast("str", got.params.get("model"))
16+
assert got_model == expected
17+
18+
1419
def check_likelihood(got: PhyloNode, expected: model_result) -> None:
1520
assert got.params["lnL"] == pytest.approx(expected.lnL)
1621

@@ -95,6 +100,7 @@ def test_fit_tree(
95100
check_motif_probs(got, expected.tree)
96101
check_rate_parameters(got, expected.tree)
97102
check_branch_lengths(got, expected.tree)
103+
check_model_name(got, str(model))
98104

99105

100106
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)