Add Triangle.ffill() to forward-fill along the origin/development axes - #1302
Open
Abhayindia wants to merge 1 commit into
Open
Add Triangle.ffill() to forward-fill along the origin/development axes#1302Abhayindia wants to merge 1 commit into
Abhayindia wants to merge 1 commit into
Conversation
Abhayindia
requested review from
genedan,
henrydingliu and
kennethshsu
as code owners
September 5, 2026 04:30
Pyright Type CompletenessView the full Project (full
Other symbols referenced but not exported by
Symbols without documentation:
Patch (exported symbols added or changed by this PR): 60.0% fully typed (3 / 5)
Patch symbol details
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1302 +/- ##
==========================================
+ Coverage 91.67% 91.70% +0.03%
==========================================
Files 93 93
Lines 5441 5462 +21
Branches 702 704 +2
==========================================
+ Hits 4988 5009 +21
Misses 328 328
Partials 125 125
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1030.
Adds
Triangle.ffill(axis), mirroring pandas'ffillbut along the origin or development axis, and never writing a value into a cell that hasn't been valued yet.On the semantics question I asked in #1030 and never got an answer to: genedan's own worked example in the issue answers it, once you check it against the triangle's actual
nan_triangle. In hisaxis=3sketch, 1987 at ages 36/48 stays missing even though 1300 precedes it - because those cells are beyond the triangle's evaluation date, not because they're a "later" NaN. Hisaxis=4example (there's no axis 4, so I read it as origin) is consistent with the same rule the whole way through: 1988 at ages 24-48 stays missing for the same reason. There's exactly one cell in the whole issue that breaks the pattern - 1986 at age 48 in theaxis=3example, which the sketch fills to 1100 even though that cell is also beyond the evaluation date. Given eleven other cells across both examples agree and only this one doesn't, I'm reading it as a typo in the hand-written sketch rather than the intended behavior, and implemented the self-consistent rule: fill forward within the observed triangle, leave everything outside it untouched.Docstring example reuses that same triangle from the issue (with the corrected 1986/48 cell) for both axes. Tests cover the development and origin directions, that it returns a new object rather than mutating in place, and the axis validation.