From 73ed09635b356fb936d9544e23aaa66483943ab2 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 21 Dec 2024 18:49:11 +0100 Subject: [PATCH 1/2] STY: Apply ruff/flake8-pie rule PIE808 PIE808 Unnecessary `start` argument in `range` --- niworkflows/interfaces/confounds.py | 2 +- niworkflows/viz/plots.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/niworkflows/interfaces/confounds.py b/niworkflows/interfaces/confounds.py index 1f7d026b2ef..08ed16c63e7 100644 --- a/niworkflows/interfaces/confounds.py +++ b/niworkflows/interfaces/confounds.py @@ -442,7 +442,7 @@ def _check_and_expand_derivative(expr, variables, data): 6th only.""" if re.search(r'^dd[0-9]+', expr): order = re.compile(r'^dd([0-9]+)').findall(expr) - order = range(0, int(*order) + 1) + order = range(int(*order) + 1) (variables, data) = temporal_derivatives(order, variables, data) elif re.search(r'^d[0-9]+[\-]?[0-9]*', expr): order = re.compile(r'^d([0-9]+[\-]?[0-9]*)').findall(expr) diff --git a/niworkflows/viz/plots.py b/niworkflows/viz/plots.py index 3ae21769cf8..5dc9ebf5462 100644 --- a/niworkflows/viz/plots.py +++ b/niworkflows/viz/plots.py @@ -414,7 +414,7 @@ def spikesplot( # Handle X axis last = ntsteps - 1 ax.set_xlim(0, last) - xticks = list(range(0, last)[::20]) + [last] if not hide_x else [] + xticks = list(range(last)[::20]) + [last] if not hide_x else [] ax.set_xticks(xticks) if not hide_x: @@ -564,7 +564,7 @@ def confoundplot( # Set 10 frame markers in X axis interval = max((ntsteps // 10, ntsteps // 5, 1)) - xticks = list(range(0, ntsteps)[::interval]) + xticks = list(range(ntsteps)[::interval]) ax_ts.set_xticks(xticks) if not hide_x: From 03cb3edf999d8d7656d397356b1ec5b53b50567b Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 21 Dec 2024 18:49:48 +0100 Subject: [PATCH 2/2] STY: Apply ruff/flake8-pie rule PIE810 PIE810 Call `endswith` once with a `tuple` --- niworkflows/interfaces/tests/test_bids.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/niworkflows/interfaces/tests/test_bids.py b/niworkflows/interfaces/tests/test_bids.py index d531d0a8e6d..3b3c991dda7 100644 --- a/niworkflows/interfaces/tests/test_bids.py +++ b/niworkflows/interfaces/tests/test_bids.py @@ -367,7 +367,7 @@ def test_DerivativesDataSink_build_path( for out, exp in zip(output, expectation): assert Path(out).relative_to(base_directory) == Path(base) / exp # Regression - some images were given nan scale factors - if out.endswith('.nii') or out.endswith('.nii.gz'): + if out.endswith(('.nii', '.nii.gz')): img = nb.load(out) if isinstance(img, nb.Nifti1Image): with nb.openers.ImageOpener(out) as fobj: