Skip to content

docs: fix lowercase option names after options refactor (#889)#895

Draft
SaguaroDev wants to merge 164 commits into
casact:experimentalfrom
SaguaroDev:889-docs-options-refactor
Draft

docs: fix lowercase option names after options refactor (#889)#895
SaguaroDev wants to merge 164 commits into
casact:experimentalfrom
SaguaroDev:889-docs-options-refactor

Conversation

@SaguaroDev
Copy link
Copy Markdown
Contributor

@SaguaroDev SaguaroDev commented May 31, 2026

Closes #889.

The options refactor on experimental added Options._validate_option(), which checks the option name against the uppercase attribute keys (ARRAY_BACKEND, AUTO_SPARSE, ARRAY_PRIORITY, ULT_VAL). Two code cells in docs/user_guide/triangle.ipynb (the "Other Parameters" / Backends section linked in the issue) still passed the old lowercase names, so they now raise:

ValueError: Invalid option(s): array_backend. Must be one of
['ARRAY_BACKEND', 'AUTO_SPARSE', 'ARRAY_PRIORITY', 'ULT_VAL'].

Fix:

  • cl.options.set_option('array_backend', 'cupy') -> 'ARRAY_BACKEND'
  • cl.options.set_option('auto_sparse', False) -> 'AUTO_SPARSE'

I grepped the whole docs/ tree for cl.options.*_option( calls — these two were the only stale ones; methods.ipynb already uses the correct uppercase 'ULT_VAL'. Notebook JSON validates after the edit.

Targeting experimental since that's where the refactor and the rendered docs in the issue live.


Note

Low Risk
Changes are documentation, docstrings, and link generation only; the only functional user-facing fix is correct option keys in a notebook example.

Overview
Updates documentation so it matches the post-refactor options API: triangle.ipynb now calls cl.options.set_option with ARRAY_BACKEND and AUTO_SPARSE instead of the removed lowercase names that trigger ValueError under Options._validate_option().

Beyond that fix, the PR is largely docs build and presentation: Sphinx autosummary templates under docs/_templates/, numpydoc_show_class_members: False, and :template: names without .rst in api.md; checked-in stubs under docs/library/generated/ are cleared so pages regenerate; linkcode handles properties and non-introspectable objects; user guide cards swap glue: figures for static images; Mack examples use grid cards; .gitignore adds docs/library/generated/. Minor docstring cleanups in chainladder (no behavior change). One bibliography URL is updated.

Reviewed by Cursor Bugbot for commit 3efc988. Bugbot is set up for automated code reviews on this repo. Configure here.

henrydingliu and others added 14 commits May 30, 2026 23:11
* Improved docstring and added examples

* Added the link ratios

* docs: add doctest examples for correlation classes

Adds Sphinx doctest Examples sections to DevelopmentCorrelation and ValuationCorrelation. Each example opens with the Mack chain-ladder assumption being tested, prints the full decision signal (statistic, confidence band, and boolean) rather than a single boolean, and ties the result back to the chain-ladder workflow.

Refs casact#704

* docs: add BootstrapODPSample doctest examples

Adds Sphinx doctest Examples section to the BootstrapODPSample class showing basic fit (resampled_triangles_.shape and scale_), downstream stochastic IBNR via Chainladder, and the effect of drop_high on scale_. Uses random_state=42 and n_sims=100 for deterministic, fast output.

Refs casact#704

* docs: reframe drop_high example as sensitivity check

Rewords the paragraph introducing the drop_high=True example to describe it as a leave-one-out sensitivity check on the column maxima rather than outlier removal, since drop_high mechanically removes the column max without any outlier test.

Addresses review feedback on casact#836.

* docs: move per-diagonal vs total mode note between testcode blocks

Per @henrydingliu review on casact#844: opening paragraph now scoped to the calendar-effect concept; the per-diagonal vs whole-triangle distinction is introduced as a transition between the two testcode blocks.

Refs casact#704

* docs: add README documenting docs build sources and outputs (refs casact#845)

* Added the transformed link ratio triangle using fit_transform to examples

* Removed the multiple testouputs

* docs: address review feedback on docs README (refs casact#845)

- Drop the jb build internals + duplicate warnings note (kennethshsu)
- Rename 'tutorial notebooks' to 'onboarding and Quickstart notebooks' (kennethshsu)
- Drop the 'What to edit for which part of the site' table and 'Known issues' section as redundant with the Source files table and casact#841 (kennethshsu)

* [REFACTOR]: Remove repetitive code. Remove dead Python 3.8 code. Add missing unit tests.

* [FIX]: Limit test to only those values meant to be changed. Use realistic values for changed options.

* [DOCS]: Finish updating Options docstring.

* [FIX]: Fix ending state of test.

* [FIX]: Reset backend after sparse-only run.

* [REFACTOR] Create template fixture for sample data sets.

* [Fix]: Remove duplicate fixture.

* [REFACTOR]: Move datetime defaults out of Options. Add validation to option getters and setters. Deprecate cl.array_backend() and cl.auto_sparse()

* FIX: Apply Bugbot fix.

* FIX: Apply Bugbot fix.

* FIX: Apply Bugbot fix.

* DOCS: Add docstring, clean up test.

* DOCS: Update docstring.

* Friedland Chapter 6 and half of Chapter 7 (casact#837)

first batch of deliverables for friedland reconstruction

* Delete docs/library/generated/chainladder.Development.rst

---------

Co-authored-by: Kenneth Hsu <kennethshsu@gmail.com>
Co-authored-by: priyam0k <87162535+priyam0k@users.noreply.github.com>
Co-authored-by: Gene Dan <genedan@gmail.com>
The options refactor added _validate_option(), which checks the option
name against the uppercase attribute keys (ARRAY_BACKEND, AUTO_SPARSE,
ARRAY_PRIORITY, ULT_VAL). Two code cells in the Triangle user guide still
passed the old lowercase names, so they raised:

    ValueError: Invalid option(s): array_backend. Must be one of
    ['ARRAY_BACKEND', 'AUTO_SPARSE', 'ARRAY_PRIORITY', 'ULT_VAL'].

Updated set_option('array_backend', ...) -> 'ARRAY_BACKEND' and
set_option('auto_sparse', ...) -> 'AUTO_SPARSE' to match the new API.

Closes casact#889.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.04%. Comparing base (449b5c1) to head (3efc988).
⚠️ Report is 34 commits behind head on experimental.

Additional details and impacted files
@@              Coverage Diff              @@
##           experimental     #895   +/-   ##
=============================================
  Coverage         87.04%   87.04%           
=============================================
  Files                86       86           
  Lines              4986     4986           
  Branches            646      646           
=============================================
  Hits               4340     4340           
  Misses              456      456           
  Partials            190      190           
Flag Coverage Δ
unittests 87.04% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@SaguaroDev
Copy link
Copy Markdown
Contributor Author

The red check here is the Doctest job, not a unit test — all seven matrix jobs (3.10–3.14, pandas3) pass. The Doctest job executes every notebook in docs/, and it's failing on docs/friedland/chapter_8.ipynb, which this PR doesn't touch (the notebook this PR edits, user_guide/triangle.ipynb, executes fine in the same run).

The RuntimeError: no running event loop / The operation was canceled at the end of the log is nbclient's async kernel-teardown crashing after the real error. The actual failure is logged earlier as a warning: chapter_8.ipynb: Executing notebook failed: CellExecutionError. The last cell passes the nested patterns dict ({'reported': {...}, 'paid': {...}}) to DevelopmentConstant(...).fit(), and the non-callable patterns path does self.patterns[12], which KeyErrors against the top-level keys.

#897 fixes that cell. It targets main, so once it lands the fix needs to reach experimental (which this PR is based on) before this Doctest job will go green. Nothing to change in this PR's own diff.

@henrydingliu
Copy link
Copy Markdown
Collaborator

thanks for pushing doc changes through experimental first.

dumb question. why does this seemingly similar valueerror on main does not trigger a doctest fail?

given our desire to keep PRs incremental, i'd like to avoid piling up too many changes on experimental, which is currently sitting at a file diff count of 50 already. I will try to get experimental merged ASAP. but may take a bit before we merge this one.

@SaguaroDev
Copy link
Copy Markdown
Contributor Author

SaguaroDev commented Jun 1, 2026

The lowercase ValueError fires on main too. It just doesn't fail the Doctest job.

MyST-NB executes every notebook (execute_notebooks: force), but a CellExecutionError during that pass is a warning, not a build error (nb_execution_raise_on_error defaults off). On main, user_guide/triangle.ipynb fails to execute on that same set_option('array_backend', ...) cell. The last green main run (8a9a46e, run 26719952136) shows it:

docs/user_guide/triangle.ipynb: WARNING: Executing notebook failed: CellExecutionError [mystnb.exec]
docs/user_guide/triangle.ipynb: WARNING: Notebook exception traceback saved in: .../triangle.err.log [mystnb.exec]

The build continues past the warning and the job stays green. The error is real, demoted to a warning, dumped to triangle.err.log.

friedland/chapter_8.ipynb is what turns the job red on this PR, and it fails differently. The last cell hits the nested-patterns KeyError, then kernel teardown throws RuntimeError: no running event loop, which propagates through jupyter_book's builder_specific_actions as a hard RuntimeError: There was an error in building your book, ending in ##[error]The operation was canceled. That is a build-process crash, not a tolerated cell warning.

Mechanism: a notebook cell raising an exception is a warning, build stays green. A kernel/process crash kills the build, job goes red. triangle.ipynb was always in the first bucket on main; chapter_8 is in the second. #897 fixes chapter_8 and targets main, so this job greens once that reaches experimental. No rush on #895. The diff is two one-word edits.

@henrydingliu henrydingliu deleted the branch casact:experimental June 3, 2026 01:16
@henrydingliu henrydingliu reopened this Jun 3, 2026
@henrydingliu
Copy link
Copy Markdown
Collaborator

@SaguaroDev can you turn this into a draft again?

@SaguaroDev SaguaroDev marked this pull request as draft June 3, 2026 16:05
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.

5 participants