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 2 #4054

Merged
merged 3 commits into from Oct 16, 2023

Conversation

ymzayek
Copy link
Member

@ymzayek ymzayek commented Oct 13, 2023

Changes proposed in this pull request:

Comment on lines -54 to +57
if sys.version_info < (3, 7): # fall back to random state for 3.6
np.random.RandomState(42)
beta = np.random.rand(nx * ny * nz, X.shape[1])
tseries_rand = scale(np.random.rand(nx * ny * nz, nt), axis=1)
else:
randome_state = np.random.default_rng(0)
beta = randome_state.random((nx * ny * nz, X.shape[1]))
tseries_rand = scale(randome_state.random((nx * ny * nz, nt)), axis=1)
rng = _rng()
beta = rng.random((nx * ny * nz, X.shape[1]))
tseries_rand = scale(rng.random((nx * ny * nz, nt)), axis=1)
Copy link
Member Author

Choose a reason for hiding this comment

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

Regarding this, we should actually upgrade the fixture to use np.random.default_rng

Copy link
Collaborator

Choose a reason for hiding this comment

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

indeed

Copy link
Collaborator

@Remi-Gau Remi-Gau left a comment

Choose a reason for hiding this comment

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

Could not spot anything wrong

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

@codecov
Copy link

codecov bot commented Oct 13, 2023

Codecov Report

Merging #4054 (3853313) into main (b6f4ff0) will increase coverage by 0.11%.
Report is 3 commits behind head on main.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #4054      +/-   ##
==========================================
+ Coverage   91.48%   91.60%   +0.11%     
==========================================
  Files         143      143              
  Lines       16076    16072       -4     
  Branches     3340     3339       -1     
==========================================
+ Hits        14707    14722      +15     
+ Misses        823      804      -19     
  Partials      546      546              
Flag Coverage Δ
macos-latest_3.10 91.49% <100.00%> (+0.02%) ⬆️
macos-latest_3.11 91.49% <100.00%> (+0.02%) ⬆️
macos-latest_3.12 91.49% <100.00%> (+0.02%) ⬆️
macos-latest_3.8 91.45% <100.00%> (+0.02%) ⬆️
macos-latest_3.9 91.46% <100.00%> (+0.02%) ⬆️
ubuntu-latest_3.10 91.49% <100.00%> (+0.02%) ⬆️
ubuntu-latest_3.11 91.49% <100.00%> (+0.02%) ⬆️
ubuntu-latest_3.12 91.49% <100.00%> (+0.02%) ⬆️
ubuntu-latest_3.8 91.45% <100.00%> (+0.02%) ⬆️
ubuntu-latest_3.9 91.46% <100.00%> (+0.02%) ⬆️
windows-latest_3.10 91.43% <100.00%> (+0.02%) ⬆️
windows-latest_3.11 91.43% <100.00%> (?)
windows-latest_3.12 91.43% <100.00%> (+0.02%) ⬆️
windows-latest_3.8 91.39% <100.00%> (+0.02%) ⬆️
windows-latest_3.9 91.40% <100.00%> (+0.02%) ⬆️

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

Files Coverage Δ
...n/interfaces/fmriprep/tests/test_load_confounds.py 100.00% <100.00%> (+1.59%) ⬆️
...rfaces/fmriprep/tests/test_load_confounds_scrub.py 100.00% <100.00%> (ø)

... and 6 files with indirect coverage changes

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

@Remi-Gau
Copy link
Collaborator

merging thenn
thanks @ymzayek

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

use rng fixture
3 participants