Skip to content

[FIX] Apply Ruff fixes to chainladder/utils. - #1290

Open
genedan wants to merge 3 commits into
mainfrom
gd_ruff_fix
Open

[FIX] Apply Ruff fixes to chainladder/utils.#1290
genedan wants to merge 3 commits into
mainfrom
gd_ruff_fix

Conversation

@genedan

@genedan genedan commented Sep 4, 2026

Copy link
Copy Markdown
Member

Summary of Changes

  • I made one change to a private method name: self._fit_OLS_thru_orig() - OLS to lowercase
  • Made an exception to _check_X(X) since capital X is taken from scikit-learn.
  • Exception also made for function PTF_formula since this is public-facing.

Related GitHub Issue(s)

#1216

Additional Context for Reviewers

Checklist

  • I passed tests locally for both code (uv run pytest) and documentation changes (uv run --directory docs jb build . --builder=custom --custom-builder=doctest)

Note

Low Risk
Mostly style and lint; the CuPy/Dask exception narrowing slightly broadens fallback behavior when optional runtimes fail at probe time, which is generally safer than swallowing all errors.

Overview
Applies Ruff cleanup across chainladder/utils (formatting, quotes, spacing, isinstance checks) and drops the per-file Ruff ignores for those modules in pyproject.toml now that they comply.

Behavioral tweaks: CuPy and Dask backend probes now catch ImportError and RuntimeError instead of a bare except, so a broken GPU/CUDA or Dask runtime falls back to NumPy with the existing warning when that backend was requested. WeightedRegression private fit helpers are renamed to _fit_ols / _fit_ols_thru_orig (call sites updated in the same file). PatsyFormula._check_X is a @staticmethod with an explicit noqa for the sklearn-style X name; public PTF_formula keeps a noqa for naming. Unused sparse.sp imports are removed from cupy.py and triangle_weight.py; Dask expand_dims uses slices instead of l.

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

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

Pyright Type Completeness

View the full pyright --verifytypes output for this commit

Project (full chainladder package, at this PR's head): 15.4% of exported symbols fully typed (213 / 1381)

Known Ambiguous Unknown Total
Project (head) 213 111 1057 1381

Other symbols referenced but not exported by chainladder: 13

Known Ambiguous Unknown Total
Other (head) 3 1 9 13

Symbols without documentation:

  • Functions without docstring: 325
  • Functions without default param: 0
  • Classes without docstring: 10

Patch (exported symbols added or changed by this PR): 100.0% fully typed (1 / 1); 1 no longer exported

Known Ambiguous Unknown Total
Patch 1 0 0 1
Patch symbol details
Symbol Status Change
chainladder.utils.tests.test_sparse.test_1d_nanquantile ✅ known new
chainladder.utils.tests.test_sparse.test_1D_nanquantile no longer exported (was ✅ known)

@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.84848% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.67%. Comparing base (8a47051) to head (2054a10).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
chainladder/utils/dask.py 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1290      +/-   ##
==========================================
- Coverage   91.68%   91.67%   -0.01%     
==========================================
  Files          93       93              
  Lines        5445     5443       -2     
  Branches      704      704              
==========================================
- Hits         4992     4990       -2     
  Misses        328      328              
  Partials      125      125              
Flag Coverage Δ
unittests 91.67% <84.84%> (-0.01%) ⬇️

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

☔ View full report in Codecov by Harness.
📢 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.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1850b44. Configure here.

Comment thread chainladder/utils/cupy.py
@genedan

genedan commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

Not sure what's going on with that codecov patch, I don't think I changed the lines in any meaningful way. We should also not go out of our way to test the dask or cupy files since they will be unsupported soon.

@henrydingliu

Copy link
Copy Markdown
Member

does #1984 need to be stacked underneath this for the test_util changes?

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.

2 participants