Skip to content

Commit 2eceee6

Browse files
committed
STY: Manual, blue-compatible touchups
[git-blame-ignore-rev]
1 parent a2eb0b7 commit 2eceee6

Some content is hidden

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

45 files changed

+442
-506
lines changed

nibabel/analyze.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ def set_slope_inter(self, slope, inter=None):
785785
"""
786786
if (slope in (None, 1) or np.isnan(slope)) and (inter in (None, 0) or np.isnan(inter)):
787787
return
788-
raise HeaderTypeError('Cannot set slope != 1 or intercept != 0 ' 'for Analyze headers')
788+
raise HeaderTypeError('Cannot set slope != 1 or intercept != 0 for Analyze headers')
789789

790790
@classmethod
791791
def _get_checks(klass):

nibabel/arraywriters.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ def _range_scale(self, in_min, in_max):
454454
if self._out_dtype.kind == 'u':
455455
if in_min < 0 and in_max > 0:
456456
raise WriterError(
457-
'Cannot scale negative and positive ' 'numbers to uint without intercept'
457+
'Cannot scale negative and positive numbers to uint without intercept'
458458
)
459459
if in_max <= 0: # All input numbers <= 0
460460
self.slope = in_min / out_max

nibabel/brikhead.py

+2-10
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,7 @@ def _unpack_var(var):
104104
TEMPLATE_SPACE ORIG
105105
"""
106106

107-
err_msg = (
108-
'Please check HEAD file to ensure it is AFNI compliant. ' f'Offending attribute:\n{var}'
109-
)
107+
err_msg = f'Please check HEAD file to ensure it is AFNI compliant. Offending attribute:\n{var}'
110108
atype, aname = TYPE_RE.findall(var), NAME_RE.findall(var)
111109
if len(atype) != 1:
112110
raise AFNIHeaderError(f'Invalid attribute type entry in HEAD file. {err_msg}')
@@ -354,13 +352,7 @@ def _calc_zooms(self):
354352
origin", and second giving "Time step (TR)".
355353
"""
356354
xyz_step = tuple(np.abs(self.info['DELTA']))
357-
t_step = self.info.get(
358-
'TAXIS_FLOATS',
359-
(
360-
0,
361-
0,
362-
),
363-
)
355+
t_step = self.info.get('TAXIS_FLOATS', (0, 0))
364356
if len(t_step) > 0:
365357
t_step = (t_step[1],)
366358
return xyz_step + t_step

nibabel/casting.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,15 @@ def type_info(np_type):
259259
if vals in (
260260
(112, 15, 16), # binary128
261261
(info_64.nmant, info_64.nexp, 8), # float64
262-
(63, 15, 12),
263-
(63, 15, 16),
264-
): # Intel extended 80
262+
(63, 15, 12), # Intel extended 80
263+
(63, 15, 16), # Intel extended 80
264+
):
265265
return ret # these are OK without modification
266266
# The remaining types are longdoubles with bad finfo values. Some we
267267
# correct, others we wait to hear of errors.
268268
# We start with float64 as basis
269269
ret = type_info(np.float64)
270-
if vals in ((52, 15, 12), (52, 15, 16)): # windows float96 # windows float128?
270+
if vals in ((52, 15, 12), (52, 15, 16)): # windows float96 / windows float128?
271271
# On windows 32 bit at least, float96 is Intel 80 storage but operating
272272
# at float64 precision. The finfo values give nexp == 15 (as for intel
273273
# 80) but in calculations nexp in fact appears to be 11 as for float64
@@ -298,7 +298,13 @@ def type_info(np_type):
298298
if np_type is np.longcomplex:
299299
max_val += 0j
300300
ret = dict(
301-
min=-max_val, max=max_val, nmant=112, nexp=15, minexp=-16382, maxexp=16384, width=width
301+
min=-max_val,
302+
max=max_val,
303+
nmant=112,
304+
nexp=15,
305+
minexp=-16382,
306+
maxexp=16384,
307+
width=width,
302308
)
303309
else: # don't recognize the type
304310
raise FloatingError(f'We had not expected long double type {np_type} with info {info}')

nibabel/cifti2/cifti2.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class Cifti2HeaderError(Exception):
7070

7171
CIFTI_MODEL_TYPES = (
7272
'CIFTI_MODEL_TYPE_SURFACE', # Modeled using surface vertices
73-
'CIFTI_MODEL_TYPE_VOXELS', # Modeled using voxels.
73+
'CIFTI_MODEL_TYPE_VOXELS', # Modeled using voxels
7474
)
7575

7676
CIFTI_SERIESUNIT_TYPES = ('SECOND', 'HERTZ', 'METER', 'RADIAN')
@@ -662,7 +662,7 @@ def __init__(self, name=None, voxel_indices_ijk=None, vertices=None):
662662
self.vertices = vertices if vertices is not None else []
663663
for val in self.vertices:
664664
if not isinstance(val, Cifti2Vertices):
665-
raise ValueError(('Cifti2Parcel vertices must be instances of ' 'Cifti2Vertices'))
665+
raise ValueError(('Cifti2Parcel vertices must be instances of Cifti2Vertices'))
666666

667667
@property
668668
def voxel_indices_ijk(self):
@@ -1237,7 +1237,7 @@ def _validate_new_mim(self, value):
12371237
a2md = self._get_indices_from_mim(value)
12381238
if not set(self.mapped_indices).isdisjoint(a2md):
12391239
raise Cifti2HeaderError(
1240-
'Indices in this Cifti2MatrixIndicesMap ' 'already mapped in this matrix'
1240+
'Indices in this Cifti2MatrixIndicesMap already mapped in this matrix'
12411241
)
12421242

12431243
def __setitem__(self, key, value):
@@ -1412,7 +1412,13 @@ class Cifti2Image(DataobjImage, SerializableImage):
14121412
rw = True
14131413

14141414
def __init__(
1415-
self, dataobj=None, header=None, nifti_header=None, extra=None, file_map=None, dtype=None
1415+
self,
1416+
dataobj=None,
1417+
header=None,
1418+
nifti_header=None,
1419+
extra=None,
1420+
file_map=None,
1421+
dtype=None,
14161422
):
14171423
"""Initialize image
14181424
@@ -1485,7 +1491,7 @@ def from_file_map(klass, file_map, *, mmap=True, keep_file_open=None):
14851491
cifti_header = item.get_content()
14861492
break
14871493
else:
1488-
raise ValueError('NIfTI2 header does not contain a CIFTI-2 ' 'extension')
1494+
raise ValueError('NIfTI2 header does not contain a CIFTI-2 extension')
14891495

14901496
# Construct cifti image.
14911497
# Use array proxy object where possible

nibabel/cifti2/cifti2_axes.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ def __add__(self, other):
665665
not np.allclose(other.affine, affine) or other.volume_shape != shape
666666
):
667667
raise ValueError(
668-
'Trying to concatenate two BrainModels defined ' 'in a different brain volume'
668+
'Trying to concatenate two BrainModels defined in a different brain volume'
669669
)
670670

671671
nvertices = dict(self.nvertices)
@@ -1008,7 +1008,7 @@ def __add__(self, other):
10081008
not np.allclose(other.affine, affine) or other.volume_shape != shape
10091009
):
10101010
raise ValueError(
1011-
'Trying to concatenate two ParcelsAxis defined ' 'in a different brain volume'
1011+
'Trying to concatenate two ParcelsAxis defined in a different brain volume'
10121012
)
10131013
nvertices = dict(self.nvertices)
10141014
for name, value in other.nvertices.items():

nibabel/cifti2/tests/test_new_cifti2.py

+47-8
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,27 @@
2020
suppress_warnings,
2121
)
2222

23-
affine = [[-1.5, 0, 0, 90], [0, 1.5, 0, -85], [0, 0, 1.5, -71], [0, 0, 0, 1.0]]
23+
affine = [
24+
[-1.5, 0, 0, 90],
25+
[0, 1.5, 0, -85],
26+
[0, 0, 1.5, -71],
27+
[0, 0, 0, 1.0],
28+
]
2429

2530
dimensions = (120, 83, 78)
2631

2732
number_of_vertices = 30000
2833

2934
brain_models = [
30-
('CIFTI_STRUCTURE_THALAMUS_LEFT', [[60, 60, 60], [61, 59, 60], [61, 60, 59], [80, 90, 92]]),
35+
(
36+
'CIFTI_STRUCTURE_THALAMUS_LEFT',
37+
[
38+
[60, 60, 60],
39+
[61, 59, 60],
40+
[61, 60, 59],
41+
[80, 90, 92],
42+
],
43+
),
3144
('CIFTI_STRUCTURE_CORTEX_LEFT', [0, 1000, 1301, 19972, 27312]),
3245
('CIFTI_STRUCTURE_CORTEX_RIGHT', [207]),
3346
]
@@ -107,7 +120,17 @@ def check_geometry_map(mapping):
107120

108121

109122
parcels = [
110-
('volume_parcel', ([[60, 60, 60], [61, 59, 60], [61, 60, 59], [80, 90, 92]],)),
123+
(
124+
'volume_parcel',
125+
(
126+
[
127+
[60, 60, 60],
128+
[61, 59, 60],
129+
[61, 60, 59],
130+
[80, 90, 92],
131+
],
132+
),
133+
),
111134
(
112135
'surface_parcel',
113136
(
@@ -117,7 +140,13 @@ def check_geometry_map(mapping):
117140
),
118141
(
119142
'mixed_parcel',
120-
([[71, 81, 39], [53, 21, 91]], ('CIFTI_STRUCTURE_CORTEX_LEFT', [71, 88, 999])),
143+
(
144+
[
145+
[71, 81, 39],
146+
[53, 21, 91],
147+
],
148+
('CIFTI_STRUCTURE_CORTEX_LEFT', [71, 88, 999]),
149+
),
121150
),
122151
('single_element', ([[71, 81, 39]], ('CIFTI_STRUCTURE_CORTEX_LEFT', [40]))),
123152
]
@@ -196,9 +225,19 @@ def check_scalar_map(mapping):
196225
(
197226
'first_name',
198227
{'meta_key': 'some_metadata'},
199-
{0: ('label0', (0.1, 0.3, 0.2, 0.5)), 1: ('new_label', (0.5, 0.3, 0.1, 0.4))},
228+
{
229+
0: ('label0', (0.1, 0.3, 0.2, 0.5)),
230+
1: ('new_label', (0.5, 0.3, 0.1, 0.4)),
231+
},
232+
),
233+
(
234+
'another name',
235+
{},
236+
{
237+
0: ('???', (0, 0, 0, 0)),
238+
1: ('great region', (0.4, 0.1, 0.23, 0.15)),
239+
},
200240
),
201-
('another name', {}, {0: ('???', (0, 0, 0, 0)), 1: ('great region', (0.4, 0.1, 0.23, 0.15))}),
202241
]
203242

204243

@@ -472,7 +511,7 @@ def test_pconnseries():
472511
hdr = ci.Cifti2Header(matrix)
473512
data = np.random.randn(4, 4, 13)
474513
img = ci.Cifti2Image(data, hdr)
475-
img.nifti_header.set_intent('NIFTI_INTENT_CONNECTIVITY_PARCELLATED_' 'PARCELLATED_SERIES')
514+
img.nifti_header.set_intent('NIFTI_INTENT_CONNECTIVITY_PARCELLATED_PARCELLATED_SERIES')
476515

477516
with InTemporaryDirectory():
478517
ci.save(img, 'test.pconnseries.nii')
@@ -496,7 +535,7 @@ def test_pconnscalar():
496535
hdr = ci.Cifti2Header(matrix)
497536
data = np.random.randn(4, 4, 2)
498537
img = ci.Cifti2Image(data, hdr)
499-
img.nifti_header.set_intent('NIFTI_INTENT_CONNECTIVITY_PARCELLATED_' 'PARCELLATED_SCALAR')
538+
img.nifti_header.set_intent('NIFTI_INTENT_CONNECTIVITY_PARCELLATED_PARCELLATED_SCALAR')
500539

501540
with InTemporaryDirectory():
502541
ci.save(img, 'test.pconnscalar.nii')

nibabel/cmdline/diff.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ def get_opt_parser():
5151
'--header-fields',
5252
dest='header_fields',
5353
default='all',
54-
help='Header fields (comma separated) to be printed as well' ' (if present)',
54+
help='Header fields (comma separated) to be printed as well (if present)',
5555
),
5656
Option(
5757
'--ma',
5858
'--data-max-abs-diff',
5959
dest='data_max_abs_diff',
6060
type=float,
6161
default=0.0,
62-
help='Maximal absolute difference in data between files' ' to tolerate.',
62+
help='Maximal absolute difference in data between files to tolerate.',
6363
),
6464
Option(
6565
'--mr',

nibabel/cmdline/ls.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import nibabel.cmdline.utils
2121
from nibabel.cmdline.utils import _err, ap, safe_get, table2string, verbose
2222

23-
__copyright__ = 'Copyright (c) 2011-18 Yaroslav Halchenko ' 'and NiBabel contributors'
23+
__copyright__ = 'Copyright (c) 2011-18 Yaroslav Halchenko and NiBabel contributors'
2424
__license__ = 'MIT'
2525

2626

nibabel/cmdline/nifti_dx.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import nibabel as nib
1616

1717
__author__ = 'Matthew Brett'
18-
__copyright__ = 'Copyright (c) 2011-18 Matthew Brett ' 'and NiBabel contributors'
18+
__copyright__ = 'Copyright (c) 2011-18 Matthew Brett and NiBabel contributors'
1919
__license__ = 'MIT'
2020

2121

nibabel/cmdline/parrec2nii.py

+4-13
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ def get_opt_parser():
4444
type='string',
4545
dest='outdir',
4646
default=None,
47-
help=one_line(
48-
"""Destination directory for NIfTI files.
49-
Default: current directory."""
50-
),
47+
help='Destination directory for NIfTI files. Default: current directory.',
5148
)
5249
)
5350
p.add_option(
@@ -81,10 +78,7 @@ def get_opt_parser():
8178
action='store_true',
8279
dest='bvs',
8380
default=False,
84-
help=one_line(
85-
"""Output bvals/bvecs files in addition to NIFTI
86-
image."""
87-
),
81+
help='Output bvals/bvecs files in addition to NIFTI image.',
8882
)
8983
)
9084
p.add_option(
@@ -207,7 +201,7 @@ def get_opt_parser():
207201
default=False,
208202
help=one_line(
209203
"""Do not discard the diagnostic Philips DTI
210-
trace volume, if it exists in the data."""
204+
trace volume, if it exists in the data."""
211205
),
212206
)
213207
)
@@ -217,10 +211,7 @@ def get_opt_parser():
217211
action='store_true',
218212
dest='overwrite',
219213
default=False,
220-
help=one_line(
221-
"""Overwrite file if it exists. Default:
222-
False"""
223-
),
214+
help='Overwrite file if it exists. Default: False',
224215
)
225216
)
226217
p.add_option(

0 commit comments

Comments
 (0)