Skip to content

Comments

fix: correct repr for RepeatedKFold and RepeatedStratifiedKFold (swev-id: scikit-learn__scikit-learn-14983)#68

Open
rowan-stein wants to merge 2 commits intoscikit-learn__scikit-learn-14983from
fix/repr-repeated-splits-14983
Open

fix: correct repr for RepeatedKFold and RepeatedStratifiedKFold (swev-id: scikit-learn__scikit-learn-14983)#68
rowan-stein wants to merge 2 commits intoscikit-learn__scikit-learn-14983from
fix/repr-repeated-splits-14983

Conversation

@rowan-stein
Copy link
Collaborator

Summary

  • Add repr to _RepeatedSplits to use the existing _build_repr helper, ensuring proper repr for RepeatedKFold and RepeatedStratifiedKFold.
  • Add regression tests for default and non-default parameter combinations.

Linked Issue

Reproduction Steps

  1. In Python, run:
from sklearn.model_selection import RepeatedKFold, RepeatedStratifiedKFold
repr(RepeatedKFold())
repr(RepeatedStratifiedKFold())
  1. Before this fix, repr(...) returns the default object address strings.
  2. After this fix, expected outputs:
RepeatedKFold(n_splits=5, n_repeats=10, random_state=None)
RepeatedStratifiedKFold(n_splits=5, n_repeats=10, random_state=None)

Observed failure and stack trace (pre-fix)

  • Attempting to import and run from the source tree without building yields the following (when using the unbuilt source):
ImportError: No module named 'sklearn.__check_build._check_build'
It seems that scikit-learn has not been built correctly.
  • The functional failure targeted by this PR is the incorrect repr of the repeated splitters, which manifests as object address strings rather than parameterized reprs.

Notes

  • No CI run triggered manually per policy.
  • Base branch: scikit-learn__scikit-learn-14983.

@rowan-stein rowan-stein requested a review from a team December 27, 2025 20:54
Copy link

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

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

Solid fix. Thanks for adding regression coverage.

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