Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: pass marginal flag to all infer_ancestral_sequences calls#602

Merged
ivan-aksamentov merged 2 commits into
masterfrom
fix/marginal-joint-fallback
Apr 23, 2026
Merged

fix: pass marginal flag to all infer_ancestral_sequences calls#602
ivan-aksamentov merged 2 commits into
masterfrom
fix/marginal-joint-fallback

Conversation

@ivan-aksamentov
Copy link
Copy Markdown
Member

TreeTime._run() builds a seq_kwargs dict containing marginal_sequences: True when branch_length_mode='marginal'. The first call to infer_ancestral_sequences correctly maps this to the marginal parameter, but three later call sites pass only **seq_kwargs. Since infer_ancestral_sequences has marginal=False as default and does not consume marginal_sequences from **kwargs, those calls silently fall back to joint reconstruction in all iterations after the first.

This PR adds marginal=seq_kwargs['marginal_sequences'] to the three affected call sites, matching the pattern already used in the initial call at line 238. A regression test monkeypatches infer_ancestral_sequences to record every marginal argument value and asserts that none are False when marginal mode is requested. Without the fix, the test fails at call #5; with the fix, all calls correctly use marginal reconstruction.

Work items

  • Add explicit marginal= argument to the post-reroot infer_ancestral_sequences call (input branch-length mode)
  • Add explicit marginal= argument to both iteration-loop infer_ancestral_sequences calls
  • Add regression test test_marginal_mode_used_in_all_iterations

Three call sites in TreeTime._run() pass **seq_kwargs to infer_ancestral_sequences without mapping marginal_sequences to the marginal parameter. The function defaults marginal=False, silently falling back to joint reconstruction in later iterations.

- Add explicit marginal=seq_kwargs['marginal_sequences'] to the post-reroot call (input mode) and both iteration-loop calls, matching the pattern already used in the initial call
- Add regression test that records every marginal argument and asserts none are False when branch_length_mode='marginal'

Fixes #601
@rneher
Copy link
Copy Markdown
Member

rneher commented Apr 23, 2026

this seems correct.

@ivan-aksamentov ivan-aksamentov merged commit dfd66f8 into master Apr 23, 2026
8 checks passed
@ivan-aksamentov ivan-aksamentov deleted the fix/marginal-joint-fallback branch April 23, 2026 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Marginal reconstructions sometimes use joint ancestral state reconstruction

2 participants