Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MAINT Remove unused _find_smallest_angle helper in _ridge.py - #34790

Merged
jeremiedbb merged 1 commit into
scikit-learn:mainfrom
VinvAI:remove-unused-find-smallest-angle
Aug 25, 2026
Merged

MAINT Remove unused _find_smallest_angle helper in _ridge.py#34790
jeremiedbb merged 1 commit into
scikit-learn:mainfrom
VinvAI:remove-unused-find-smallest-angle

Conversation

@noQbot

@noQbot noQbot commented Aug 21, 2026

Copy link
Copy Markdown

Reference Issues/PRs

No issue - small dead-code cleanup. The helper was left behind when the eigen-GCV
intercept path moved to an explicit G^-1 correction in _solve_eigen_gram (#33020).

What does this implement/fix? Explain your changes.

_find_smallest_angle used to find the intercept eigenvector in _RidgeGCV's
eigen-GCV path. Once that path switched to computing the intercept correction
directly in _solve_eigen_gram, nothing called it anymore. It's private,
unexported, and grep finds it only at its own definition - no callers in the code,
tests, or docs.

So this just deletes the function (19 lines). Ridge and RidgeCV behave exactly the
same; there's no API with a caller to break.

Introduce yourself

I'm Anshul, working on Vinv - it traces running Python services to find dead code,
hotspots, and runtime errors without changing the source. scikit-learn is a
dependency in our own pipeline, so it goes through the same analysis. Vinv's
dead-code pass flagged _find_smallest_angle: no callers in the traces we captured,
no static references. I went and read the code, saw the eigen-GCV caller was already
gone, and sent this.

AI usage disclosure

Models: Composer 2.5 (via Cursor + VinvAI)

Prompt (paraphrased): act on Vinv's dead-code finding for _find_smallest_angle,
confirm it's genuinely unreferenced (no static references anywhere in code, tests,
or docs; not exported; no dynamic lookup by name; and its former eigen-GCV caller
was replaced by the _solve_eigen_gram intercept correction), then delete it.

AI transcript
  • Vinv's dead-code sweep flagged _find_smallest_angle in
    sklearn/linear_model/_ridge.py as unreferenced.
  • Verified before deleting:
    • Repo-wide grep for _find_smallest_angle → only the definition site matched
      (code, tests, and docs).
    • Confirmed it is private, not in any __all__, and not re-exported.
    • Confirmed the only symbol it used (get_namespace) is still used elsewhere in
      the module, so its import stays.
  • Deleted the function.
  • Ran python -m py_compile sklearn/linear_model/_ridge.py → compiles clean.

Any other comments?

No changelog entry - it's an internal helper with no callers, so nothing user-facing
changes. I can add one if you'd rather. Verified locally that the module still
compiles and get_namespace is still used elsewhere.

_find_smallest_angle located the intercept eigenvector in the old
_RidgeGCV eigen-GCV path. That path was replaced by an explicit
G^-1 intercept correction in _solve_eigen_gram, leaving this helper
with no remaining callers. It is a private function, not referenced
anywhere in the codebase, tests, or docs, and not exported.

Ridge/RidgeCV behavior is unchanged.

Co-Authored-By: Vinv-AI <[email protected]>
@github-actions

Copy link
Copy Markdown

Thank you for opening your first pull request to scikit-learn! 🎉

To help get your contribution reviewed, please make sure that:

  • You have filled out the pull request template.

  • The pull request addresses an existing issue that is ready for contribution (e.g. not tagged as 'Needs Triage', 'Needs Decision', ...). If you are proposing a new feature, please open an issue to discuss it first.

  • There are no other open pull requests already targeting the same issue.

  • You have followed the pull request checklist. In particular, linting and tests should pass.

@jeremiedbb jeremiedbb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the clean-up

@jeremiedbb
jeremiedbb merged commit a456b32 into scikit-learn:main Aug 25, 2026
42 checks passed
prady0t pushed a commit to prady0t/scikit-learn that referenced this pull request Sep 2, 2026
@jeremiedbb jeremiedbb mentioned this pull request Sep 8, 2026
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants