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] refactor tests regions extractions #3931

Merged
merged 5 commits into from Aug 29, 2023

Conversation

Remi-Gau
Copy link
Collaborator

@Remi-Gau Remi-Gau commented Aug 28, 2023

@Remi-Gau
Copy link
Collaborator Author

Those new tests were added by #3732

Will try to implement some CI check that makes sure that the length (number of lines) of our tests does not increase beyond a certain threshold.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 28, 2023

👋 @Remi-Gau 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 Aug 28, 2023

Codecov Report

Merging #3931 (4bace13) into main (23da827) will not change coverage.
Report is 1 commits behind head on main.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #3931   +/-   ##
=======================================
  Coverage   91.77%   91.77%           
=======================================
  Files         134      134           
  Lines       15750    15750           
  Branches     3283     3283           
=======================================
  Hits        14454    14454           
  Misses        752      752           
  Partials      544      544           
Flag Coverage Δ
macos-latest_3.10 91.68% <ø> (ø)
macos-latest_3.11 ?
macos-latest_3.8 ?
macos-latest_3.9 ?
ubuntu-latest_3.10 91.68% <ø> (?)
ubuntu-latest_3.8 91.64% <ø> (ø)
ubuntu-latest_3.9 91.64% <ø> (ø)
windows-latest_3.10 91.62% <ø> (ø)
windows-latest_3.11 91.62% <ø> (ø)
windows-latest_3.8 91.59% <ø> (ø)
windows-latest_3.9 91.59% <ø> (ø)

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

@ymzayek ymzayek left a comment

Choose a reason for hiding this comment

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

LGTM and thanks for adding that flake8 check

@Remi-Gau
Copy link
Collaborator Author

actually something is strange: the flake8 check should have failed at some point I think.

@@ -11,7 +11,7 @@ exclude =
nilearn_cache
venv,
doc/_build
--select = D,E,F,W,C90
--select = D,E,F,W,C90,CFQ
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

check for errors regarding code quality of functions

@@ -41,7 +41,7 @@ per-file-ignores =
examples/*/*: D103, D205, D301, D400
# - docstrings rules that should not be applied to doc
doc/*: D100, D103, F401
ignore = D105, D107, E402, W503, W504, W605, BLK100
ignore = D105, D107, E402, W503, W504, W605, BLK100, CFQ003
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we got some non pure functions in the test suite: silencing this error for now.
will try to address later

./nilearn/decoding/tests/test_same_api.py:81:1: CFQ003 Function "test_same_energy_calculus_pure_lasso" is not pure.
./nilearn/decoding/tests/test_same_api.py:125:1: CFQ003 Function "test_graph_net_and_tvl1_same_for_pure_l1" is not pure.
./nilearn/decoding/tests/test_same_api.py:163:1: CFQ003 Function "test_graph_net_and_tvl1_same_for_pure_l1_BaseSpaceNet" is not pure.
./nilearn/decoding/tests/test_same_api.py:204:1: CFQ003 Function "test_graph_net_and_tvl1_same_for_pure_l1_logistic" is not pure.
./nilearn/decoding/tests/test_same_api.py:232:1: CFQ003 Function "test_graph_net_and_tvl1_same_for_pure_l1_logistic_spacenet_classifier" is not pure.
./nilearn/decoding/tests/test_same_api.py:266:1: CFQ003 Function "test_graph_net_and_tv_same_for_pure_l1_another_test" is not pure.
./nilearn/decoding/tests/test_space_net.py:441:1: CFQ003 Function "test_space_net_alpha_grid_pure_spatial" is not pure.

Comment on lines +35 to +41
run: python -m pip install --upgrade pip flake8 flake8-docstrings flake8-use-fstring flake8-functions

- name: Run Flake8 on whole file
shell: bash {0}
run: flake8 --verbose .

- name: Ensure that tests functions are not too long
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this checks code quality of the function of the whole code base (with the very lax constraints we have for now in the flake8 config)

and specifically checks for too long functions in the test suite

@Remi-Gau Remi-Gau merged commit 9ae8199 into nilearn:main Aug 29, 2023
29 checks passed
@Remi-Gau Remi-Gau deleted the refactor/tests_regions branch August 29, 2023 19: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

2 participants