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] avoid creating files during testing: test_infer_effect_maps #3716

Merged
merged 7 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 0 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,3 @@ examples/results/
examples/*.nii
examples/*.nii.gz
examples/*.png

# created during testing
fmri_run0.nii
fmri_run1.nii
dmtx_0.csv
dmtx_1.csv
mask.nii
bids_dataset
8 changes: 2 additions & 6 deletions nilearn/glm/tests/test_second_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,16 +284,15 @@ def test_get_contrast():
assert _get_contrast([1, 0], design_matrix) == 'conf1'


def test_infer_effect_maps():
def test_infer_effect_maps(tmp_path, monkeypatch):
monkeypatch.chdir(tmp_path)
from nilearn.glm.second_level.second_level import _infer_effect_maps

# with InTemporaryDirectory():
shapes, rk = ((7, 8, 9, 1), (7, 8, 7, 16)), 3
mask, fmri_data, design_matrices = write_fake_fmri_data_and_design(
shapes,
rk
)
func_img = load(fmri_data[0])
second_level_input = pd.DataFrame({'map_name': ["a", "b"],
'effects_map_path': [fmri_data[0],
"bar"]})
Expand All @@ -307,9 +306,6 @@ def test_infer_effect_maps():
model.fit(fmri_data[i],
design_matrices=design_matrices[i])
assert len(_infer_effect_maps(second_level_input, contrast)) == 2
# Delete objects attached to files to avoid WindowsError when deleting
# temporary directory (in Windows)
del mask, fmri_data, func_img, second_level_input


def test_high_level_glm_with_paths():
Expand Down