Remi-Gau / nilearn

Machine learning for NeuroImaging in Python
http://nilearn.github.io
Other
1 stars 1 forks source link

Sourcery refactored main branch #1

Closed sourcery-ai[bot] closed 1 year ago

sourcery-ai[bot] commented 2 years ago

Branch main refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the main branch, then run:

git fetch origin sourcery/main
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

pep8speaks commented 2 years ago

Hello @sourcery-ai[bot]! Thanks for opening this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 41:80: E501 line too long (81 > 79 characters) Line 45:80: E501 line too long (85 > 79 characters) Line 49:80: E501 line too long (85 > 79 characters)

Line 76:80: E501 line too long (81 > 79 characters) Line 80:80: E501 line too long (85 > 79 characters) Line 84:80: E501 line too long (85 > 79 characters)

Line 22:80: E501 line too long (87 > 79 characters) Line 26:80: E501 line too long (87 > 79 characters) Line 115:50: E127 continuation line over-indented for visual indent

Line 31:80: E501 line too long (87 > 79 characters)

Line 43:80: E501 line too long (82 > 79 characters)

Line 75:80: E501 line too long (94 > 79 characters) Line 79:80: E501 line too long (96 > 79 characters)

Line 39:80: E501 line too long (81 > 79 characters)

Line 158:80: E501 line too long (96 > 79 characters)

Line 30:80: E501 line too long (82 > 79 characters)

Line 43:80: E501 line too long (82 > 79 characters)

Line 60:80: E501 line too long (87 > 79 characters) Line 64:80: E501 line too long (87 > 79 characters) Line 68:80: E501 line too long (91 > 79 characters)

Line 168:80: E501 line too long (87 > 79 characters) Line 176:80: E501 line too long (84 > 79 characters)

Line 39:80: E501 line too long (82 > 79 characters)

Line 116:19: E231 missing whitespace after ':' Line 116:19: E701 multiple statements on one line (colon) Line 116:20: E225 missing whitespace around operator

Line 421:80: E501 line too long (82 > 79 characters) Line 900:80: E501 line too long (81 > 79 characters) Line 903:80: E501 line too long (82 > 79 characters) Line 905:80: E501 line too long (80 > 79 characters) Line 929:80: E501 line too long (81 > 79 characters) Line 933:80: E501 line too long (81 > 79 characters) Line 937:80: E501 line too long (82 > 79 characters)

Line 733:21: E231 missing whitespace after ':' Line 733:21: E701 multiple statements on one line (colon) Line 733:22: E225 missing whitespace around operator

Line 71:80: E501 line too long (182 > 79 characters)

Line 80:5: E303 too many blank lines (2)

Line 276:80: E501 line too long (81 > 79 characters)

Line 132:80: E501 line too long (81 > 79 characters) Line 162:25: E126 continuation line over-indented for hanging indent

Line 19:13: W503 line break before binary operator Line 25:61: W504 line break after binary operator Line 169:80: E501 line too long (81 > 79 characters)

Line 271:80: E501 line too long (82 > 79 characters)

Line 155:80: E501 line too long (105 > 79 characters)

Line 484:80: E501 line too long (155 > 79 characters) Line 556:17: E128 continuation line under-indented for visual indent Line 557:17: E128 continuation line under-indented for visual indent Line 558:17: E124 closing bracket does not match visual indentation

Line 315:80: E501 line too long (82 > 79 characters)

Line 103:80: E501 line too long (98 > 79 characters) Line 108:80: E501 line too long (109 > 79 characters) Line 112:5: E303 too many blank lines (2) Line 1866:80: E501 line too long (85 > 79 characters) Line 1871:80: E501 line too long (103 > 79 characters) Line 1876:80: E501 line too long (106 > 79 characters)

Line 266:80: E501 line too long (81 > 79 characters) Line 687:80: E501 line too long (93 > 79 characters) Line 694:80: E501 line too long (93 > 79 characters) Line 1977:9: W503 line break before binary operator Line 2084:80: E501 line too long (87 > 79 characters) Line 2097:80: E501 line too long (87 > 79 characters) Line 2108:17: E231 missing whitespace after ':' Line 2108:17: E701 multiple statements on one line (colon) Line 2108:18: E225 missing whitespace around operator

Line 660:13: W503 line break before binary operator Line 1402:5: E303 too many blank lines (2) Line 1629:80: E501 line too long (145 > 79 characters)

Line 660:80: E501 line too long (98 > 79 characters)

Line 667:80: E501 line too long (83 > 79 characters) Line 767:80: E501 line too long (83 > 79 characters)

Line 529:80: E501 line too long (83 > 79 characters)

Line 439:80: E501 line too long (83 > 79 characters)

Line 43:21: E231 missing whitespace after ':' Line 43:21: E701 multiple statements on one line (colon) Line 43:22: E225 missing whitespace around operator Line 571:51: E127 continuation line over-indented for visual indent Line 571:80: E501 line too long (85 > 79 characters) Line 622:80: E501 line too long (94 > 79 characters) Line 883:80: E501 line too long (83 > 79 characters) Line 896:80: E501 line too long (114 > 79 characters) Line 908:80: E501 line too long (87 > 79 characters) Line 915:80: E501 line too long (210 > 79 characters)

Line 121:80: E501 line too long (103 > 79 characters) Line 147:80: E501 line too long (91 > 79 characters)

Line 204:17: W503 line break before binary operator Line 205:17: W503 line break before binary operator

Line 150:80: E501 line too long (86 > 79 characters) Line 195:80: E501 line too long (86 > 79 characters)

Line 789:80: E501 line too long (103 > 79 characters)

Line 735:80: E501 line too long (175 > 79 characters) Line 742:80: E501 line too long (129 > 79 characters) Line 792:80: E501 line too long (80 > 79 characters)

Line 27:80: E501 line too long (114 > 79 characters) Line 179:13: W503 line break before binary operator

sourcery-ai[bot] commented 2 years ago

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.25%.

Quality metrics Before After Change
Complexity 6.97 ⭐ 6.66 ⭐ -0.31 👍
Method Length 124.36 😞 123.69 😞 -0.67 👍
Working memory 10.51 😞 10.53 😞 0.02 👎
Quality 56.08% 🙂 56.33% 🙂 0.25% 👍
Other metrics Before After Change
Lines 28225 28307 82
Changed files Quality Before Quality After Quality Change
doc/conf.py 60.85% 🙂 61.82% 🙂 0.97% 👍
doc/sphinxext/gh_substitutions.py 83.22% ⭐ 82.87% ⭐ -0.35% 👎
examples/00_tutorials/plot_decoding_tutorial.py 40.11% 😞 40.10% 😞 -0.01% 👎
examples/01_plotting/plot_atlas.py 83.28% ⭐ 83.00% ⭐ -0.28% 👎
examples/01_plotting/plot_carpet.py 49.87% 😞 49.80% 😞 -0.07% 👎
examples/01_plotting/plot_colormaps.py 48.95% 😞 52.19% 🙂 3.24% 👍
examples/01_plotting/plot_demo_plotting.py 68.41% 🙂 68.22% 🙂 -0.19% 👎
examples/01_plotting/plot_haxby_masks.py 55.38% 🙂 55.28% 🙂 -0.10% 👎
examples/01_plotting/plot_surf_atlas.py 44.18% 😞 45.71% 😞 1.53% 👍
examples/01_plotting/plot_surf_stat_map.py 48.66% 😞 48.61% 😞 -0.05% 👎
examples/01_plotting/plot_visualization.py 66.39% 🙂 66.22% 🙂 -0.17% 👎
examples/02_decoding/plot_haxby_anova_svm.py 54.70% 🙂 54.61% 🙂 -0.09% 👎
examples/02_decoding/plot_haxby_different_estimators.py 30.15% 😞 30.16% 😞 0.01% 👍
examples/02_decoding/plot_haxby_full_analysis.py 37.67% 😞 37.62% 😞 -0.05% 👎
examples/02_decoding/plot_haxby_grid_search.py 33.56% 😞 33.55% 😞 -0.01% 👎
examples/02_decoding/plot_haxby_multiclass.py 45.53% 😞 45.51% 😞 -0.02% 👎
examples/02_decoding/plot_haxby_searchlight.py 44.54% 😞 44.51% 😞 -0.03% 👎
examples/02_decoding/plot_haxby_searchlight_surface.py 48.61% 😞 48.50% 😞 -0.11% 👎
examples/02_decoding/plot_miyawaki_encoding.py 48.46% 😞 49.16% 😞 0.70% 👍
examples/02_decoding/plot_miyawaki_reconstruction.py 49.48% 😞 49.26% 😞 -0.22% 👎
examples/02_decoding/plot_oasis_vbm.py 39.20% 😞 39.19% 😞 -0.01% 👎
examples/03_connectivity/plot_atlas_comparison.py 62.80% 🙂 62.19% 🙂 -0.61% 👎
examples/03_connectivity/plot_compare_decomposition.py 50.42% 🙂 50.40% 🙂 -0.02% 👎
examples/03_connectivity/plot_data_driven_parcellations.py 36.39% 😞 36.39% 😞 0.00%
examples/03_connectivity/plot_group_level_connectivity.py 32.03% 😞 32.03% 😞 0.00%
examples/03_connectivity/plot_inverse_covariance_connectome.py 63.09% 🙂 63.02% 🙂 -0.07% 👎
examples/03_connectivity/plot_multi_subject_connectome.py 59.92% 🙂 59.82% 🙂 -0.10% 👎
examples/03_connectivity/plot_probabilistic_atlas_extraction.py 64.16% 🙂 64.09% 🙂 -0.07% 👎
examples/03_connectivity/plot_signal_extraction.py 43.20% 😞 38.95% 😞 -4.25% 👎
examples/03_connectivity/plot_sphere_based_connectome.py 34.90% 😞 34.90% 😞 0.00%
examples/04_glm_first_level/plot_bids_features.py 48.56% 😞 48.55% 😞 -0.01% 👎
examples/04_glm_first_level/plot_fiac_analysis.py 63.47% 🙂 63.38% 🙂 -0.09% 👎
examples/04_glm_first_level/plot_hrf.py 70.48% 🙂 70.14% 🙂 -0.34% 👎
examples/04_glm_first_level/plot_predictions_residuals.py 38.09% 😞 38.09% 😞 0.00%
examples/04_glm_first_level/plot_spm_multimodal_faces.py 40.98% 😞 41.00% 😞 0.02% 👍
examples/04_glm_first_level/plot_write_events_file.py 61.16% 🙂 61.13% 🙂 -0.03% 👎
examples/05_glm_second_level/plot_second_level_association_test.py 49.85% 😞 49.83% 😞 -0.02% 👎
examples/05_glm_second_level/plot_second_level_design_matrix.py 70.41% 🙂 70.67% 🙂 0.26% 👍
examples/05_glm_second_level/plot_second_level_one_sample_test.py 41.55% 😞 41.55% 😞 0.00%
examples/06_manipulating_images/plot_compare_mean_image.py 81.23% ⭐ 80.94% ⭐ -0.29% 👎
examples/06_manipulating_images/plot_mask_computation.py 48.34% 😞 48.32% 😞 -0.02% 👎
examples/06_manipulating_images/plot_nifti_labels_simple.py 65.65% 🙂 65.56% 🙂 -0.09% 👎
examples/06_manipulating_images/plot_nifti_simple.py 59.74% 🙂 59.67% 🙂 -0.07% 👎
examples/06_manipulating_images/plot_roi_extraction.py 36.87% 😞 36.86% 😞 -0.01% 👎
examples/06_manipulating_images/plot_smooth_mean_image.py 80.68% ⭐ 80.53% ⭐ -0.15% 👎
examples/07_advanced/plot_advanced_decoding_scikit.py 38.46% 😞 38.46% 😞 0.00%
examples/07_advanced/plot_bids_analysis.py 49.34% 😞 49.30% 😞 -0.04% 👎
examples/07_advanced/plot_haxby_mass_univariate.py 40.17% 😞 40.16% 😞 -0.01% 👎
examples/07_advanced/plot_ica_resting_state.py 66.56% 🙂 66.47% 🙂 -0.09% 👎
examples/07_advanced/plot_localizer_mass_univariate_methods.py 46.40% 😞 46.39% 😞 -0.01% 👎
examples/07_advanced/plot_neurovault_meta_analysis.py 75.32% ⭐ 74.82% 🙂 -0.50% 👎
maint_tools/show-python-packages-versions.py 88.79% ⭐ 88.71% ⭐ -0.08% 👎
nilearn/masking.py 57.03% 🙂 57.30% 🙂 0.27% 👍
nilearn/signal.py 57.62% 🙂 58.38% 🙂 0.76% 👍
nilearn/version.py 77.70% ⭐ 77.69% ⭐ -0.01% 👎
nilearn/_utils/cache_mixin.py 43.70% 😞 43.68% 😞 -0.02% 👎
nilearn/_utils/class_inspect.py 70.08% 🙂 70.26% 🙂 0.18% 👍
nilearn/_utils/data_gen.py 42.02% 😞 41.48% 😞 -0.54% 👎
nilearn/_utils/docs.py 46.05% 😞 48.36% 😞 2.31% 👍
nilearn/_utils/glm.py 68.67% 🙂 68.75% 🙂 0.08% 👍
nilearn/_utils/helpers.py 83.91% ⭐ 82.54% ⭐ -1.37% 👎
nilearn/_utils/logger.py 55.68% 🙂 61.56% 🙂 5.88% 👍
nilearn/_utils/niimg.py 70.49% 🙂 70.89% 🙂 0.40% 👍
nilearn/_utils/niimg_conversions.py 34.18% 😞 34.84% 😞 0.66% 👍
nilearn/_utils/numpy_conversions.py 41.17% 😞 44.93% 😞 3.76% 👍
nilearn/_utils/path_finding.py 82.74% ⭐ 82.58% ⭐ -0.16% 👎
nilearn/_utils/segmentation.py 57.52% 🙂 57.10% 🙂 -0.42% 👎
nilearn/_utils/testing.py 62.25% 🙂 64.27% 🙂 2.02% 👍
nilearn/connectome/connectivity_matrices.py 53.07% 🙂 53.39% 🙂 0.32% 👍
nilearn/connectome/tests/test_connectivity_matrices.py 49.82% 😞 51.21% 🙂 1.39% 👍
nilearn/datasets/_testing.py 77.87% ⭐ 77.92% ⭐ 0.05% 👍
nilearn/datasets/atlas.py 52.99% 🙂 53.21% 🙂 0.22% 👍
nilearn/datasets/func.py 46.67% 😞 46.51% 😞 -0.16% 👎
nilearn/datasets/neurovault.py 71.74% 🙂 71.87% 🙂 0.13% 👍
nilearn/datasets/struct.py 58.57% 🙂 59.82% 🙂 1.25% 👍
nilearn/datasets/utils.py 41.25% 😞 41.02% 😞 -0.23% 👎
nilearn/datasets/data/convert_templates.py 48.43% 😞 48.35% 😞 -0.08% 👎
nilearn/datasets/tests/test_atlas.py 70.66% 🙂 70.84% 🙂 0.18% 👍
nilearn/datasets/tests/test_func.py 70.33% 🙂 70.14% 🙂 -0.19% 👎
nilearn/datasets/tests/test_neurovault.py 76.20% ⭐ 76.61% ⭐ 0.41% 👍
nilearn/datasets/tests/test_struct.py 73.18% 🙂 73.40% 🙂 0.22% 👍
nilearn/datasets/tests/test_testing.py 73.13% 🙂 73.16% 🙂 0.03% 👍
nilearn/datasets/tests/test_utils.py 65.55% 🙂 65.51% 🙂 -0.04% 👎
nilearn/decoding/decoder.py 41.44% 😞 41.52% 😞 0.08% 👍
nilearn/decoding/fista.py 14.28% ⛔ 14.80% ⛔ 0.52% 👍
nilearn/decoding/objective_functions.py 77.42% ⭐ 77.55% ⭐ 0.13% 👍
nilearn/decoding/proximal_operators.py 29.17% 😞 30.36% 😞 1.19% 👍

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
nilearn/_utils/data_gen.py create_fake_bids_dataset 57 ⛔ 557 ⛔ 24 ⛔ 4.63% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
nilearn/datasets/func.py fetch_localizer_contrasts 47 ⛔ 883 ⛔ 5.64% ⛔ Refactor to reduce nesting. Try splitting into smaller methods
nilearn/decoding/proximal_operators.py _prox_tvl1 45 ⛔ 473 ⛔ 28 ⛔ 6.04% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
nilearn/decoding/fista.py mfista 38 ⛔ 419 ⛔ 28 ⛔ 8.48% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
nilearn/datasets/utils.py _fetch_file 33 ⛔ 552 ⛔ 28 ⛔ 9.58% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!