Skip to content

Commit 39429f9

Browse files
MNT: run ruff --fix and ruf format
Also fix remaining issues manually.
1 parent 733c0f3 commit 39429f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+79
-128
lines changed

doc/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030

3131
# Check for external Sphinx extensions we depend on
3232
try:
33-
import numpydoc
33+
import numpydoc # noqa: F401
3434
except ImportError:
3535
raise RuntimeError('Need to install "numpydoc" package for doc build')
3636
try:
37-
import texext
37+
import texext # noqa: F401
3838
except ImportError:
3939
raise RuntimeError('Need to install "texext" package for doc build')
4040

doc/tools/apigen.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,6 @@ def discover_modules(self):
405405

406406
def write_modules_api(self, modules, outdir):
407407
# upper-level modules
408-
main_module = modules[0].split('.')[0]
409408
ulms = [
410409
'.'.join(m.split('.')[:2]) if m.count('.') >= 1 else m.split('.')[0] for m in modules
411410
]

doc/tools/build_modref_templates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def abort(error):
3838

3939
try:
4040
__import__(package)
41-
except ImportError as e:
41+
except ImportError:
4242
abort('Can not import ' + package)
4343

4444
module = sys.modules[package]

nibabel/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#
88
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
99

10+
# ruff: noqa: F401
11+
1012
import os
1113

1214
from .info import long_description as __doc__
@@ -39,12 +41,10 @@
3941

4042
# module imports
4143
from . import analyze as ana
42-
from . import ecat, imagestats, mriutils
44+
from . import ecat, imagestats, mriutils, orientations, streamlines, viewers
4345
from . import nifti1 as ni1
44-
from . import orientations
4546
from . import spm2analyze as spm2
4647
from . import spm99analyze as spm99
47-
from . import streamlines, viewers
4848

4949
# isort: split
5050

nibabel/benchmarks/bench_arrayproxy_slicing.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656

5757

5858
def bench_arrayproxy_slicing():
59-
6059
print_git_title('\nArrayProxy gzip slicing')
6160

6261
# each test is a tuple containing
@@ -100,7 +99,6 @@ def fmt_sliceobj(sliceobj):
10099
return f"[{', '.join(slcstr)}]"
101100

102101
with InTemporaryDirectory():
103-
104102
print(f'Generating test data... ({int(round(np.prod(SHAPE) * 4 / 1048576.0))} MB)')
105103

106104
data = np.array(np.random.random(SHAPE), dtype=np.float32)
@@ -128,7 +126,6 @@ def fmt_sliceobj(sliceobj):
128126
seeds = [np.random.randint(0, 2**32) for s in SLICEOBJS]
129127

130128
for ti, test in enumerate(tests):
131-
132129
label = get_test_label(test)
133130
have_igzip, keep_open, sliceobj = test
134131
seed = seeds[SLICEOBJS.index(sliceobj)]

nibabel/cifti2/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# copyright and license terms.
77
#
88
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
9+
# ruff: noqa: F401
910
"""CIFTI-2 format IO
1011
1112
.. currentmodule:: nibabel.cifti2

nibabel/cifti2/tests/test_cifti2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pytest
88

99
from nibabel import cifti2 as ci
10-
from nibabel.cifti2.cifti2 import Cifti2HeaderError, _float_01, _value_if_klass
10+
from nibabel.cifti2.cifti2 import _float_01, _value_if_klass
1111
from nibabel.nifti2 import Nifti2Header
1212
from nibabel.tests.test_dataobj_images import TestDataobjAPI as _TDA
1313
from nibabel.tests.test_image_api import DtypeOverrideMixin, SerializeMixin

nibabel/cifti2/tests/test_cifti2io_header.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#
88
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
99

10-
import io
1110
from os.path import dirname
1211
from os.path import join as pjoin
1312

@@ -38,7 +37,7 @@
3837

3938

4039
def test_space_separated_affine():
41-
img = ci.Cifti2Image.from_filename(pjoin(NIBABEL_TEST_DATA, 'row_major.dconn.nii'))
40+
_ = ci.Cifti2Image.from_filename(pjoin(NIBABEL_TEST_DATA, 'row_major.dconn.nii'))
4241

4342

4443
def test_read_nifti2():

nibabel/cmdline/diff.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ def get_data_diff(files, max_abs=0, max_rel=0, dtype=np.float64):
231231
diffs1 = [None] * (i + 1)
232232

233233
for j, d2 in enumerate(data[i + 1 :], i + 1):
234-
235234
if d1.shape == d2.shape:
236235
abs_diff = np.abs(d1 - d2)
237236
mean_abs = (np.abs(d1) + np.abs(d2)) * 0.5
@@ -255,7 +254,6 @@ def get_data_diff(files, max_abs=0, max_rel=0, dtype=np.float64):
255254
max_rel_diff = 0
256255

257256
if np.any(candidates):
258-
259257
diff_rec = OrderedDict() # so that abs goes before relative
260258

261259
diff_rec['abs'] = max_abs_diff.astype(dtype)
@@ -268,7 +266,6 @@ def get_data_diff(files, max_abs=0, max_rel=0, dtype=np.float64):
268266
diffs1.append({'CMP': 'incompat'})
269267

270268
if any(diffs1):
271-
272269
diffs['DATA(diff %d:)' % (i + 1)] = diffs1
273270

274271
return diffs

nibabel/cmdline/tests/test_convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def test_convert_imgtype(tmp_path, ext, img_class):
119119

120120
def test_convert_nifti_int_fail(tmp_path):
121121
infile = get_test_data(fname='anatomical.nii')
122-
outfile = tmp_path / f'output.nii'
122+
outfile = tmp_path / 'output.nii'
123123

124124
orig = nib.load(infile)
125125
assert not outfile.exists()

0 commit comments

Comments
 (0)