Skip to content

Fix flaky test_shuffle_streamlines by seeding the shuffle - #1369

Merged
arnaudbore merged 2 commits into
masterfrom
copilot/fix-failing-github-actions-job
Oct 21, 2026
Merged

arnaudbore merged 2 commits into
masterfrom
copilot/fix-failing-github-actions-job

Conversation

Copilot AI commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Quick description

The test CI job failed on test_shuffle_streamlines. The test shuffles a 4-streamline tractogram without a seed and asserts the result differs from the input. A uniform shuffle of 4 items returns the identity permutation 1 time in 24 (~4%), so the assertion fails at random.

  • Test fix: test_shuffle_streamlines now calls shuffle_streamlines(sft, rng_seed=0). I checked in plain Python that random.seed(0) followed by random.shuffle on 4 items gives [2, 0, 1, 3], a non-identity order. The test is now deterministic.
  • No production code changes.
sft2 = shuffle_streamlines(sft, rng_seed=0)
assert not sft2 == sft

Type of change

Check the relevant options.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Provide data, screenshots, command line to test (if relevant)

pytest src/scilpy/tractograms/tests/test_tractogram_operations.py::test_shuffle_streamlines

I have not run this test locally. The sandbox had no numpy installed.

Checklist

  • My code follows the style guidelines of this project (run autopep8)
  • I added relevant citations to scripts, modules and functions docstrings and descriptions
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I moved all functions from the script file (except the argparser and main) to scilpy modules
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Co-authored-by: frheault <10820351+frheault@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix the failing GitHub Actions job test Fix flaky test_shuffle_streamlines by seeding the shuffle Oct 20, 2026
Copilot AI requested a review from frheault October 20, 2026 16:57
@frheault

Copy link
Copy Markdown
Member

@arnaudbore This kept failling in another PR and so I tried ''fix with copilot''
(It is pretty simple)

@frheault
frheault marked this pull request as ready for review October 21, 2026 15:58
@codecov

codecov Bot commented Oct 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.57%. Comparing base (588a49a) to head (329d813).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1369      +/-   ##
==========================================
- Coverage   72.58%   72.57%   -0.02%     
==========================================
  Files         301      301              
  Lines       26279    26279              
  Branches     3702     3702              
==========================================
- Hits        19075    19072       -3     
  Misses       5654     5654              
- Partials     1550     1553       +3     
Flag Coverage Δ
smoketests 69.73% <ø> (-0.02%) ⬇️
unittests 14.22% <ø> (-0.01%) ⬇️

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

Components Coverage Δ
Scripts 75.28% <ø> (-0.03%) ⬇️
Library 69.32% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@arnaudbore
arnaudbore added this pull request to the merge queue Oct 21, 2026
Merged via the queue into master with commit 2810fe2 Oct 21, 2026
3 checks passed
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.

3 participants