perf(tl): vectorize ancestral_states sum for array data#56
Conversation
Replace the per-feature tree traversal loop with a single bottom-up pass using numpy for the sum method, reducing complexity from O(n_nodes * n_features) tree traversals to one. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #56 +/- ##
==========================================
+ Coverage 93.99% 94.04% +0.04%
==========================================
Files 35 35
Lines 2983 3004 +21
==========================================
+ Hits 2804 2825 +21
Misses 179 179
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 789fad2729
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| result = np.nansum(stacked, axis=0) | ||
| result[np.all(np.isnan(stacked), axis=0)] = np.nan |
There was a problem hiding this comment.
Preserve NaNs when summing array-valued descendants
Using np.nansum here changes the sum reconstruction semantics by treating missing child values as zero instead of propagating missingness. In the previous per-index implementation (and still in scalar sum), a child value of NaN made the parent NaN for that feature ([NaN, 2] -> NaN), but this branch now returns 2. That silently converts unknown measurements into observed totals and can materially change reconstructed ancestral states for arrays with partial missing data.
Useful? React with 👍 / 👎.
Summary
summethodTest plan
ancestral_statestests passsumoutput against previous implementation🤖 Generated with Claude Code