Repository navigation
Conversation
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): 0.0% fully typed (0 / 2)
Patch symbol details
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1557 +/- ##
=======================================
Coverage 94.59% 94.59%
=======================================
Files 98 98
Lines 6233 6237 +4
Branches 799 799
=======================================
+ Hits 5896 5900 +4
Misses 216 216
Partials 121 121
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:
|
|
converting to draft due to branch conflict |
| ) | ||
| obj.values = func(obj.values, axis=axis, *args, **kwargs) | ||
| else: | ||
| with warnings.catch_warnings(): |
There was a problem hiding this comment.
the intent of the if statement is to only let the empty slice or All-NaN slice warnings fire when there is an empty origin or an empty development. i'm concerned that removing the condition results in the warning being silenced too often.
There was a problem hiding this comment.
Localizing the filter inside CaseOutstanding.fit around the mean call keeps pandas.py untouched. I can update this here.
| self.case_ldf_.values = case_to_prior_case_naned.mean(axis=2).values | ||
| self.case_ldf_ = case_to_prior_case_naned.mean(axis=2) | ||
| xp = self.case_ldf_.get_array_module() | ||
| self.case_ldf_.values[xp.isnan(self.case_ldf_.values)] = 1.0 |
There was a problem hiding this comment.
can this be routed through the existing fillna method?
There was a problem hiding this comment.
Routing through self.case_ldf_.fillna(1.0) works cleanly here and avoids touching the array values directly
| self.paid_ldf_.values = paid_to_prior_case_naned.mean(axis=2).values | ||
| self.paid_ldf_ = paid_to_prior_case_naned.mean(axis=2) | ||
| xp = self.paid_ldf_.get_array_module() | ||
| self.paid_ldf_.values[xp.isnan(self.paid_ldf_.values)] = 0.0 |
There was a problem hiding this comment.
can this be routed through the existing fillzero method?
if you are thinking, why do we have a separate fillna and fillzero? well, ideally we don't.
There was a problem hiding this comment.
Switching to fillzero() makes sense here. Learned something new about the fillna(0) history
| assert model.paid_ldf_ is not None | ||
| assert not model.case_ldf_.to_frame().isna().any().any() | ||
|
|
||
| # Synthetic triangle with zero prior case |
There was a problem hiding this comment.
should this be two tests if we are using two datasets?
There was a problem hiding this comment.
Splitting into two separate tests (one for the XYZ auto tail runoff and one for the synthetic intermediate zero case) will make failures much easier to isolate.
|
|
||
| # Synthetic triangle with zero prior case | ||
|
|
||
| def test_case_outstanding_synthetic_zero_prior_case_warning(): |
There was a problem hiding this comment.
Will do, I will pull the synthetic zero-case setup into a pytest fixture to keep the test body clean
Summary of Changes
CaseOutstanding.case_to_prior_case_andpaid_to_prior_case_withnum_to_nan()to guard against divide-by-zero when carried case reserves run off to zero..mean(2)calls infit()with directmean(axis=2)assignment, defaulting residualcase_ldf_NaNs to1.0andpaid_ldf_NaNs to0.0.RuntimeWarningfilter inTrianglePandas.agg_funcacross all axes so triangle aggregations match pandas behavior.test_outstanding.pycovering tail runoff onfriedland_xyz_auto_biand zero prior case reserves under strict warning checks.Related GitHub Issue(s)
Closes #1509
AI/LLM Usage
Used basic model for drafting initial unit test assertions and lint checks.
Additional Context for Reviewers
Defaulting residual
case_ldf_NaNs to1.0matches existing behavior in_set_ldf()and follows conventions inDevelopmentandMunichAdjustment.Submitter's Checklist
[FIX],[FEAT],[DOCS],[TST],[CHORE], or[BRK]).Reviewer's Checklist
Note
Medium Risk
Changes reserve-ratio math and default LDF fill behavior in CaseOutstanding fit(), which can shift projections when case reserves hit zero; scope is limited to that estimator plus new tests.
Overview
CaseOutstanding now treats zero prior case reserves as invalid denominators by passing prior-case values through
num_to_nan()incase_to_prior_case_andpaid_to_prior_case_, avoiding divide-by-zero when case has fully runoff.During
fit(), pattern means are taken directly from weighted, NaN-masked triangles (mean(axis=2)), withcase_ldf_NaNs filled to 1.0 andpaid_ldf_NaNs filled to 0 viafillzero(). RuntimeWarnings from empty or all-NaN slices while aggregating are suppressed in that block.Tests assert fitting on real and synthetic triangles with zero case reserves completes without
RuntimeWarningand yields non-NaNcase_ldf_/ validpaid_ldf_.Reviewed by Cursor Bugbot for commit 841a1ac. Bugbot is set up for automated code reviews on this repo. Configure here.