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

Skip to content

DOC Fix docstring defaults that do not match the signature - #34772

Merged
ArturoAmorQ merged 1 commit into
scikit-learn:mainfrom
SEPURI-SAI-KRISHNA:doc-fix-wrong-documented-defaults
Aug 20, 2026
Merged

DOC Fix docstring defaults that do not match the signature#34772
ArturoAmorQ merged 1 commit into
scikit-learn:mainfrom
SEPURI-SAI-KRISHNA:doc-fix-wrong-documented-defaults

Conversation

@SEPURI-SAI-KRISHNA

Copy link
Copy Markdown

Reference Issues/PRs

None. These are docstring-only corrections where the documented default contradicts
the signature, which the Documentation section of the pull request checklist exempts
from needing an issue ("typos or obvious inconsistencies in the documentation").


What does this implement/fix? Explain your changes.

Nine parameters in seven files documented a default value that the function or
class signature contradicts. This PR corrects the docstrings to match the code. No
behaviour is changed.

function / class parameter docstring said signature says
HalvingGridSearchCV return_train_score default=False True (_search_successive_halving.py:758)
HalvingRandomSearchCV return_train_score default=False True (_search_successive_halving.py:1139)
randomized_svd random_state default='warn' None (extmath.py:411)
spectral_clustering n_clusters default=None 8 (_spectral.py:197)
spectral_clustering n_components default=n_clusters None (_spectral.py:198)
fetch_lfw_people min_faces_per_person default=None 0 (_lfw.py:271)
SequentialFeatureSelector cv default=None 5 (_sequential.py:191)
TargetEncoder cv default=None 5 (_target_encoder.py:245)
MiniBatchNMF verbose bool, default=False 0 (_nmf.py:1993)

Two of these are settled by the codebase itself:

  • SpectralClustering the class already documents n_clusters : int, default=8
    (_spectral.py:407) and n_components : int, default=None ... If None, defaults to n_clusters. The spectral_clustering function in the same module disagrees with
    both. These changes make the function match the class.
  • NMF documents verbose : int, default=0 (_nmf.py:1458), so do the three private helpers
    in that module (lines 453, 788, 1069). MiniBatchNMF is the only one
    documenting it as bool / False.

randomized_svd's default='warn' is left over from a deprecation cycle that ended
in 1.2; the signature has been None since then.


Introduce yourself

I am saikrishna working as a senior data engineer I have bachelors degree in computer science with data analytics specialization where I have worked on wide variety of tools like numpy, pandas, scikit-learn,... Where I have done various projects using various tools. Now I was reading the source looking for a bug to fix. So I wanted to contribute and help tool perform better.


AI usage disclosure

I used AI assistance for:

  • Documentation (including examples)
  • Research and understanding

This pull request includes code written with the assistance of AI.
The code has not yet been reviewed by a human.


Any other comments?

On return_train_score: BaseSearchCV defaults this to False (_search.py:1696,
_search.py:2095), while both halving classes override it to True. I have documented
the behaviour as it currently is. Whether the True override was intended is a
behaviour question and I did not want to fold it into a documentation PR; happy to open
a separate issue if that is worth looking at. If reviewers would rather not touch that
one here, it can be dropped and the other eight are unaffected.

No changelog entry: check-changelog.yml only requires one when a file matching
sklearn/.+test_.+\.py changes, and this PR touches no test files.

Checks run locally: sklearn/tests/test_docstrings.py,
sklearn/tests/test_docstring_parameters.py and
sklearn/tests/test_docstring_parameters_consistency.py (2939 passed), the test modules
for all seven touched files (826 passed), and ruff 0.12.2 check and format.

@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.

@ArturoAmorQ ArturoAmorQ changed the title DOC fix documented defaults that do not match the code DOC Fix docstring defaults that do not match the signature Aug 20, 2026
@ArturoAmorQ
ArturoAmorQ merged commit 5315378 into scikit-learn:main Aug 20, 2026
43 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
jeremiedbb pushed a commit to jeremiedbb/scikit-learn that referenced this pull request Sep 8, 2026
jeremiedbb pushed a commit to jeremiedbb/scikit-learn that referenced this pull request Sep 9, 2026
jeremiedbb pushed a commit to jeremiedbb/scikit-learn that referenced this pull request Sep 9, 2026
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