Skip to content

Commit

Permalink
[FIX] address flaky tests in CI (#3785)
Browse files Browse the repository at this point in the history
* remove duplicate tests

* skip test for now

* only skip test

* silence more tests

* ignore all parcellations tests

* skip one more test

* only run parcellation tests

* refactor tests

* reintroduce test

* reintroduce test

* bring yet another test back in

* switch ubuntu version for doc

* test on all

* use latet
  • Loading branch information
Remi-Gau committed Jun 29, 2023
1 parent ee21258 commit 089a1a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
# This prevents this workflow from running on a fork.
# To test this workflow on a fork, uncomment the following line.
if: github.repository == 'nilearn/nilearn'
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
timeout-minutes: 360
env:
BROWSER: "/usr/bin/firefox"
Expand Down
28 changes: 11 additions & 17 deletions nilearn/regions/tests/test_parcellations.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,6 @@ def test_parcellations_fit_on_multi_nifti_images(method, test_image):

assert parcellator.labels_img_ is not None

parcellator = Parcellations(method="rena", n_parcels=5, verbose=0)
parcellator.fit(fmri_imgs)

assert parcellator.labels_img_ is not None

parcellator = Parcellations(
method="hierarchical_kmeans", n_parcels=5, verbose=0
)
parcellator.fit(fmri_imgs)

assert parcellator.labels_img_ is not None

# Smoke test with explicit mask image
mask_img = np.ones((10, 11, 12))
mask_img = Nifti1Image(mask_img, AFFINE_EYE)
Expand Down Expand Up @@ -243,20 +231,26 @@ def test_parcellations_transform_with_multi_confounds_multi_images(
@pytest.mark.parametrize("method", METHODS)
@pytest.mark.parametrize("n_parcel", [5])
def test_fit_transform(method, n_parcel, test_image_2):
rng = np.random.RandomState(42)
fmri_imgs = [test_image_2] * 3
confounds = rng.standard_normal(size=(10, 3))
confounds_list = [confounds] * 3

parcellator = Parcellations(method=method, n_parcels=n_parcel, verbose=0)
signals = parcellator.fit_transform(fmri_imgs)
parcellator.fit_transform(fmri_imgs)

assert parcellator.labels_img_ is not None
if method not in ["kmeans", "rena", "hierarchical_kmeans"]:
assert parcellator.connectivity_ is not None
assert parcellator.masker_ is not None

# fit_transform with confounds

@pytest.mark.parametrize("method", METHODS)
@pytest.mark.parametrize("n_parcel", [5])
def test_fit_transform_with_condounds(method, n_parcel, test_image_2):
rng = np.random.RandomState(42)
fmri_imgs = [test_image_2] * 3
confounds = rng.standard_normal(size=(10, 3))
confounds_list = [confounds] * 3

parcellator = Parcellations(method=method, n_parcels=n_parcel, verbose=0)
signals = parcellator.fit_transform(fmri_imgs, confounds=confounds_list)

assert isinstance(signals, list)
Expand Down

0 comments on commit 089a1a0

Please sign in to comment.