Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MAINT] Use rng fixture for setting up np.random.RandomState() - part 1 #4052

Merged
merged 4 commits into from Oct 17, 2023

Conversation

ymzayek
Copy link
Member

@ymzayek ymzayek commented Oct 13, 2023

Changes proposed in this pull request:

  • Use rng fixture in modules _utils, connectome, datasets, decoding, decomposition, glm

@github-actions
Copy link
Contributor

👋 @ymzayek Thanks for creating a PR!

Until this PR is ready for review, you can include the [WIP] tag in its title, or leave it as a github draft.

Please make sure it is compliant with our contributing guidelines. In particular, be sure it checks the boxes listed below.

  • PR has an interpretable title.
  • PR links to Github issue with mention Closes #XXXX (see our documentation on PR structure)
  • Code is PEP8-compliant (see our documentation on coding style)
  • Changelog or what's new entry in doc/changes/latest.rst (see our documentation on PR structure)

For new features:

  • There is at least one unit test per new function / class (see our documentation on testing)
  • The new feature is demoed in at least one relevant example.

For bug fixes:

  • There is at least one test that would fail under the original bug conditions.

We will review it as quick as possible, feel free to ping us with questions if needed.

Co-authored-by: Remi Gau <remi_gau@hotmail.com>
@codecov
Copy link

codecov bot commented Oct 13, 2023

Codecov Report

Merging #4052 (4af8880) into main (96755a4) will not change coverage.
Report is 3 commits behind head on main.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #4052   +/-   ##
=======================================
  Coverage   91.60%   91.60%           
=======================================
  Files         143      143           
  Lines       16072    16072           
  Branches     3339     3339           
=======================================
  Hits        14722    14722           
  Misses        804      804           
  Partials      546      546           
Flag Coverage Δ
macos-latest_3.10 91.49% <ø> (ø)
macos-latest_3.11 91.49% <ø> (ø)
macos-latest_3.12 91.49% <ø> (ø)
macos-latest_3.8 91.45% <ø> (ø)
macos-latest_3.9 91.46% <ø> (ø)
ubuntu-latest_3.10 91.49% <ø> (ø)
ubuntu-latest_3.11 91.49% <ø> (ø)
ubuntu-latest_3.12 91.49% <ø> (ø)
ubuntu-latest_3.8 91.45% <ø> (ø)
ubuntu-latest_3.9 91.46% <ø> (ø)
windows-latest_3.10 ?
windows-latest_3.11 91.43% <ø> (ø)
windows-latest_3.12 ?
windows-latest_3.8 91.39% <ø> (ø)
windows-latest_3.9 91.40% <ø> (ø)

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

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@bthirion bthirion left a comment

Choose a reason for hiding this comment

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

LGTM, thx !

@@ -5,14 +5,14 @@
from nibabel import Nifti1Image
from sklearn.model_selection import KFold

from nilearn.conftest import _rng
from nilearn.decoding import searchlight


def _make_searchlight_test_data(frames):
Copy link
Member

Choose a reason for hiding this comment

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

Why not make rng an argument of the test in that case ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

AFAICT because rng is a fixture and fixtures can only be passed as arguments to a test function (or another fixture) but not to a utility function (pretty sure it is more complicated than that but this is the super short version)

# If design matrix contains an intercept, the
# mean of the residuals should be 0 (short of
# some numerical rounding errors)
Xintercept[:, 0] = 1
model = OLSModel(design=Xintercept)
X[:, 0] = 1
Copy link
Member

Choose a reason for hiding this comment

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

Isn't X modified ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah but it gets regenerated every time the fixture is invoked so eventhough it is modified in this test, the next test will get a "fresh new X".

@Remi-Gau Remi-Gau merged commit 0817b96 into nilearn:main Oct 17, 2023
32 checks passed
@ymzayek ymzayek deleted the use-rng-fixture branch November 7, 2023 12:14
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.

None yet

3 participants