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
Conversation
👋 @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.
For new features:
For bug fixes:
We will review it as quick as possible, feel free to ping us with questions if needed. |
Codecov Report
@@ 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
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 |
There was a problem hiding this 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): |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't X modified ?
There was a problem hiding this comment.
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".
Changes proposed in this pull request: