Skip to content

TST/CI fix test_cython_solver_early_stopping to pass all random seeds in CI - #34961

Merged
lesteve merged 4 commits into
scikit-learn:mainfrom
lorentzenchr:fix_cd_test
Oct 3, 2026
Merged

lesteve merged 4 commits into
scikit-learn:mainfrom
lorentzenchr:fix_cd_test

Conversation

@lorentzenchr

Copy link
Copy Markdown
Member

Reference Issues/PRs

Fixes #34732.

What does this implement/fix? Explain your changes.

AI usage disclosure

None

@lorentzenchr

Copy link
Copy Markdown
Member Author

@lesteve You might be interested.
Some [all random sees] tests still fail (non that I introduced):

  • cluster/tests/test_bicluster.py::test_spectral_biclustering
  • metrics/tests/test_pairwise_distances_reduction.py::test_format_agnosticism[

So this PR is a net improvement.

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

Thank you @lorentzenchr!
From what I understand here we make the test looser, so it can pass more generally on different data. The failing checks on [all random seeds] are indeed not a problem, because this touches other tests.

I'd have two comments:

  1. Can we change the comment that says "# avoid all zeros" into something like "# assert if first fit is meaningful", or similar?

  2. I think we should also apply global_random_seed on this test and use it in make_regression because we want all our tests to be reproducible.

@lesteve

lesteve commented Oct 2, 2026

Copy link
Copy Markdown
Member

Thanks for the PR @lorentzenchr!

I think we should also apply global_random_seed on this test and use it in make_regression because we want all our tests to be reproducible.

Yep, definitely agree with this. Let's use make_regression(random_state=global_random_seed) to make this test deterministic.

You might be interested. Some [all random sees] tests still fail (non that I introduced):

I am not interested, don't try to nerd-snipe me into a CI wild goose chase 😅. I think we both agree that it's not worth chasing these global_random_seed issues too much. IIRC the compromise we reached (for now) was:

  • all tests 100 seeds (0-99 IIRC)
  • the CI tests samples randomly in seeds 0-19 (SKLEARN_TESTS_GLOBAL_RANDOM_SEED=$((RANDOM % 20))

@lesteve

lesteve commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

If you really want to, I guess we could do something like this, PR welcome 😉 (I definitely don't think this is very important, so no pressure):

  • all => 0-19
  • extended => 0-99

The naming could be different ci-like (0-19) vs all (0-99) or better names, suggestions more than welcome. Again I don't think this is super important ...

@lesteve lesteve added this to Labs Oct 2, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Labs Oct 2, 2026
@lesteve

lesteve commented Oct 2, 2026

Copy link
Copy Markdown
Member

A variant of this was seens in wheel tests as well, so it'd be nice to fix it, see build log

FAILED linear_model/tests/test_coordinate_descent.py::test_cython_solver_early_stopping[enet_gram]

@lesteve

lesteve commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

@lorentzenchr I just refrained myself very hard to do it myself and to push into your branch directly, because I wasn't 100% sure how you would feel about it 😉.

@lesteve
lesteve merged commit 9bbd337 into scikit-learn:main Oct 3, 2026
37 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Labs Oct 3, 2026
@lesteve

lesteve commented Oct 3, 2026

Copy link
Copy Markdown
Member

Merging, thanks!

@lorentzenchr
lorentzenchr deleted the fix_cd_test branch October 3, 2026 10:25
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.

⚠️ CI failed on Unit tests Linux pymin_conda_forge_arm (last failure: Aug 12, 2026) ⚠️

3 participants