Repository navigation
Conversation
Huyvux12
requested review from
genedan,
henrydingliu and
kennethshsu
as code owners
November 25, 2026 04:23
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 / 4)
Patch symbol details
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1709 +/- ##
=======================================
Coverage 95.21% 95.22%
=======================================
Files 100 100
Lines 6604 6616 +12
Branches 831 833 +2
=======================================
+ Hits 6288 6300 +12
Misses 200 200
Partials 116 116
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 #1707
What was wrong
ClarkLDF.fitkeptminimize(...).xand never readsuccess, so failedoptimizer fits were kept silently with finite
ldf_and no warning.TailBondy.fittooklogofldf_at the fit ages and handed it toleast_squares, so a NaN factor surfaced as scipy's genericValueError: Initial guess is outside of provided bounds, which does notpoint at the data.
Fix
chainladder/development/clark.py: after eachminimizecall, warn(
UserWarning) naming the triangle (index label) and column, plus theoptimizer message and status, when
successis False. The failed fit isstill kept, as before; only the silence is fixed.
chainladder/tails/bondy.py: before callingleast_squares, check thelog-development factors for finiteness and raise a
ValueErrornamingevery fit age with no finite development factor and the column.
Repro (base SHA
0f4b230c, scipy 1.18.1, fresh venv)Before the fix, the issue's snippets give:
status (status 2) yet are kept silently — Reverted the full_expectation_ to the old method of calculating expected values per #269 #273 First Amer Ins Co /
ppauto (NaN objective) and Development lags could not be determined #683 Star Ins Grp / ppauto (x at the lower
bounds). The issue lists 4; the count varies a little by build, but the
defect is the same.
ValueError: Initial guess is outside of provided bounds, all 226 witha non-finite log of the last development factor, exactly as reported.
After the fix:
ClarkLDF().fit(clrd.iloc[273])warns:ClarkLDF optimization did not converge for triangle ('First Amer Ins Co', 'ppauto') (column 'CumPaidLoss'): ABNORMAL: (status 2). The fitted omega_ and theta_ may be unreliable.Same for Development lags could not be determined #683. A healthygeninsfit stays silent.TailBondy().fit(clrd.iloc[2])raises:TailBondy cannot fit: no finite development factor at age(s) 108 for column 'CumPaidLoss'. ...With
earliest_age=12it listsage(s) 84, 96, 108.A healthy
raafit still works (tail 1.0092, as in the docstring).Regression tests
chainladder/development/tests/test_clark.py:test_clark_ldf_warns_when_optimizer_fails(deterministic fakeminimizereturningsuccess=False, asserts the warning names thetriangle and carries the optimizer message) and
test_clark_ldf_no_warning_when_optimizer_succeeds(control case).chainladder/tails/tests/test_bondy.py:test_bondy_rejects_non_finite_development_factorandtest_bondy_names_each_non_finite_fit_age.Regression scope
pytest chainladder/development/tests/test_clark.py chainladder/tails/tests/test_bondy.py: 14 passed.pytest chainladder/tails/tests/ chainladder/development/tests/test_clark.py chainladder/development/tests/test_development.py chainladder/methods/tests/test_predict.py: 208 passed, 6 failed.The 6 failures are pre-existing on the clean tree (same 6 fail with
this PR stashed):
test_development.py::test_drop_*trips a numpy 2.5DeprecationWarninginchainladder/core/base.py, untouched here.ruff checkandruff format --checkpass on all changed files.Risks checked and excluded
failed: any non-finite factor made
least_squaresraise before (NaNresiduals, or a NaN starting value), so no previously succeeding fit
now fails. No existing test expects the old scipy message (none
references it).
leaves fitted values untouched; the grouped-clrd docstring fit emits
no warning and matches its published
omega_values.minimizer_kwargsanda
minimizer_results_attribute. This PR does not add that attribute,so it stays out of [FEAT] Pass minimizer_kwargs from ClarkLDF to scipy.optimize.minimize #1541's way; the warning reads the
OptimizeResultdirectly instead.