Thanks to visit codestin.com
Credit goes to github.com

Skip to content

CI: Add specs and style checks #3321

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

Merged
merged 7 commits into from
Apr 5, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Commits with messages like "STY: black" or "run black"
f64bf338f630a9ee5cbe7a3ec98c68292897e720
83358d7f17aac07cb90d0330f11ea2322e2974d8
faef7d0f93013a700c882f709e98fb3cd36ebb03
d50c1858564c0b3073fb23c54886a0454cb66afa
417b8897a116fcded5000e21e2b6ccbe29452a52
aaf677a87f64c485f3e305799e4a5dc73b69e5fb
f763008442d88d8ce00ec266698268389415f8d6
b1eccafd4edc8503b02d715f5b5f6f783520fdf9
70db90349598cc7f26a4a513779529fba7d0a797
6c1d91d71f6f0db0e985bd2adc34206442b0653d
97bdbd5f48ab242de5288ba4715192a27619a803
78fa360f5b785224349b8b85b07e510d2233bb63
7f85f43a34de8bff8e634232c939b17cee8e8fc5
9c50b5daa797def5672dd057155b0e2c658853e2
47194993ae14aceeec436cfb3769def667196668
75653feadc6667d5313d83e9c62a5d5819771a9c
497b44d680eee0892fa59c6aaaae22a17d70a536
76 changes: 76 additions & 0 deletions .github/workflows/contrib.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Contribution checks

# This checks validate contributions meet baseline checks
#
# * specs - Ensure make

on:
push:
branches:
- master
- maint/*
pull_request:
branches:
- master
- maint/*

defaults:
run:
shell: bash

jobs:
stable:
# Check each OS, all supported Python, minimum versions and latest releases
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ['ubuntu-18.04']
python-version: [3.8]
nipype-extras: ['dev']
check: ['specs', 'style']
env:
DEPENDS: ""
CHECK_TYPE: ${{ matrix.check }}
NIPYPE_EXTRAS: ${{ matrix.nipype-extras }}
EXTRA_PIP_FLAGS: ""
INSTALL_DEB_DEPENDENCIES: false
INSTALL_TYPE: pip
CI_SKIP_TEST: 1

steps:
- uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Create virtual environment
run: tools/ci/create_venv.sh
- name: Build archive
run: |
source tools/ci/build_archive.sh
echo "ARCHIVE=$ARCHIVE" >> $GITHUB_ENV
- name: Install Debian dependencies
run: tools/ci/install_deb_dependencies.sh
if: ${{ matrix.os == 'ubuntu-18.04' }}
- name: Install dependencies
run: tools/ci/install_dependencies.sh
- name: Install Nipype
run: tools/ci/install.sh
- name: Run tests
run: tools/ci/check.sh
if: ${{ matrix.check != 'skiptests' }}
- uses: codecov/codecov-action@v1
with:
file: coverage.xml
if: ${{ always() }}
- name: Upload pytest test results
uses: actions/upload-artifact@v2
with:
name: pytest-results-${{ matrix.os }}-${{ matrix.python-version }}
path: test-results.xml
if: ${{ always() && matrix.check == 'test' }}
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.0.0
rev: v3.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 19.3b0
rev: 20.8b1
hooks:
- id: black
5 changes: 2 additions & 3 deletions nipype/algorithms/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ class DistanceOutputSpec(TraitedSpec):


class Distance(BaseInterface):
"""Calculates distance between two volumes.
"""
"""Calculates distance between two volumes."""

input_spec = DistanceInputSpec
output_spec = DistanceOutputSpec
Expand Down Expand Up @@ -542,7 +541,7 @@ class ErrorMapOutputSpec(TraitedSpec):


class ErrorMap(BaseInterface):
""" Calculates the error (distance) map between two input volumes.
"""Calculates the error (distance) map between two input volumes.

Example
-------
Expand Down
6 changes: 2 additions & 4 deletions nipype/algorithms/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ class SimpleThresholdOutputSpec(TraitedSpec):


class SimpleThreshold(BaseInterface):
"""Applies a threshold to input volumes
"""
"""Applies a threshold to input volumes"""

input_spec = SimpleThresholdInputSpec
output_spec = SimpleThresholdOutputSpec
Expand Down Expand Up @@ -240,8 +239,7 @@ class CreateNiftiOutputSpec(TraitedSpec):


class CreateNifti(BaseInterface):
"""Creates a nifti volume
"""
"""Creates a nifti volume"""

input_spec = CreateNiftiInputSpec
output_spec = CreateNiftiOutputSpec
Expand Down
30 changes: 13 additions & 17 deletions nipype/algorithms/modelgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ def spm_hrf(RT, P=None, fMRI_T=16):
% p - parameters of the response function (two gamma
% functions)
% defaults (seconds)
% p(0) - delay of response (relative to onset) 6
% p(1) - delay of undershoot (relative to onset) 16
% p(2) - dispersion of response 1
% p(3) - dispersion of undershoot 1
% p(4) - ratio of response to undershoot 6
% p(5) - onset (seconds) 0
% p(6) - length of kernel (seconds) 32
% p(0) - delay of response (relative to onset) 6
% p(1) - delay of undershoot (relative to onset) 16
% p(2) - dispersion of response 1
% p(3) - dispersion of undershoot 1
% p(4) - ratio of response to undershoot 6
% p(5) - onset (seconds) 0
% p(6) - length of kernel (seconds) 32
%
% hrf - hemodynamic response function
% p - parameters of the response function
Expand Down Expand Up @@ -135,7 +135,7 @@ def scale_timings(timelist, input_units, output_units, time_repetition):


def bids_gen_info(
bids_event_files, condition_column="", amplitude_column=None, time_repetition=False,
bids_event_files, condition_column="", amplitude_column=None, time_repetition=False
):
"""
Generate a subject_info structure from a list of BIDS .tsv event files.
Expand Down Expand Up @@ -471,8 +471,7 @@ def _generate_standard_design(
return sessinfo

def _generate_design(self, infolist=None):
"""Generate design specification for a typical fmri paradigm
"""
"""Generate design specification for a typical fmri paradigm"""
realignment_parameters = []
if isdefined(self.inputs.realignment_parameters):
for parfile in self.inputs.realignment_parameters:
Expand Down Expand Up @@ -517,8 +516,7 @@ def _generate_design(self, infolist=None):
)

def _run_interface(self, runtime):
"""
"""
""""""
self._sessioninfo = None
self._generate_design()
return runtime
Expand Down Expand Up @@ -739,7 +737,7 @@ class SpecifySparseModelOutputSpec(SpecifyModelOutputSpec):


class SpecifySparseModel(SpecifyModel):
""" Specify a sparse model that is compatible with SPM/FSL designers [1]_.
"""Specify a sparse model that is compatible with SPM/FSL designers [1]_.

Examples
--------
Expand Down Expand Up @@ -770,8 +768,7 @@ class SpecifySparseModel(SpecifyModel):
output_spec = SpecifySparseModelOutputSpec

def _gen_regress(self, i_onsets, i_durations, i_amplitudes, nscans):
"""Generates a regressor for a sparse/clustered-sparse acquisition
"""
"""Generates a regressor for a sparse/clustered-sparse acquisition"""
bplot = False
if isdefined(self.inputs.save_plot) and self.inputs.save_plot:
bplot = True
Expand Down Expand Up @@ -901,8 +898,7 @@ def _gen_regress(self, i_onsets, i_durations, i_amplitudes, nscans):
return reg

def _cond_to_regress(self, info, nscans):
"""Converts condition information to full regressors
"""
"""Converts condition information to full regressors"""
reg = []
regnames = []
for i, cond in enumerate(info.conditions):
Expand Down
6 changes: 2 additions & 4 deletions nipype/algorithms/rapidart.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,7 @@ def _detect_outliers_core(self, imgfile, motionfile, runidx, cwd=None):
save_json(statsfile, stats)

def _run_interface(self, runtime):
"""Execute this module.
"""
"""Execute this module."""
funcfilelist = ensure_list(self.inputs.realigned_files)
motparamlist = ensure_list(self.inputs.realignment_parameters)
for i, imgf in enumerate(funcfilelist):
Expand Down Expand Up @@ -814,8 +813,7 @@ def _get_spm_submatrix(self, spmmat, sessidx, rows=None):
return outmatrix

def _run_interface(self, runtime):
"""Execute this module.
"""
"""Execute this module."""
import scipy.io as sio

motparamlist = self.inputs.realignment_parameters
Expand Down
4 changes: 2 additions & 2 deletions nipype/algorithms/tests/test_TSNR.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def test_tsnr_withpoly3(self):

@mock.patch("warnings.warn")
def test_warning(self, mock_warn):
""" test that usage of misc.TSNR trips a warning to use
confounds.TSNR instead """
"""test that usage of misc.TSNR trips a warning to use
confounds.TSNR instead"""
# run
misc.TSNR(in_file=self.in_filenames["in_file"])

Expand Down
6 changes: 3 additions & 3 deletions nipype/algorithms/tests/test_modelgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def test_modelgen1(tmpdir):
np.array([6.0, 6.0]),
)
npt.assert_almost_equal(
np.array(res.outputs.session_info[0]["cond"][1]["duration"]), np.array([6.0,])
np.array(res.outputs.session_info[0]["cond"][1]["duration"]), np.array([6.0])
)
npt.assert_almost_equal(
np.array(res.outputs.session_info[1]["cond"][1]["duration"]),
Expand Down Expand Up @@ -191,14 +191,14 @@ def test_modelgen_spm_concat(tmpdir):
np.array([1.0, 1.0]),
)
npt.assert_almost_equal(
np.array(res.outputs.session_info[0]["cond"][1]["duration"]), np.array([1.0,])
np.array(res.outputs.session_info[0]["cond"][1]["duration"]), np.array([1.0])
)
npt.assert_almost_equal(
np.array(res.outputs.session_info[1]["cond"][1]["duration"]),
np.array([1.0, 1.0]),
)
npt.assert_almost_equal(
np.array(res.outputs.session_info[2]["cond"][1]["duration"]), np.array([1.0,])
np.array(res.outputs.session_info[2]["cond"][1]["duration"]), np.array([1.0])
)

# Test case for variable number of events in concatenated runs, sometimes unique.
Expand Down
Loading