Skip to content

Commit 60e4af9

Browse files
committed
STY: Manual, blue-compatible touchups
[git-blame-ignore-rev]
1 parent 8acd559 commit 60e4af9

40 files changed

+113
-118
lines changed

Diff for: 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):

Diff for: 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

Diff for: 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

Diff for: 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}')

Diff for: 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

Diff for: 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():

Diff for: nibabel/cifti2/tests/test_new_cifti2.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ def test_pconnseries():
472472
hdr = ci.Cifti2Header(matrix)
473473
data = np.random.randn(4, 4, 13)
474474
img = ci.Cifti2Image(data, hdr)
475-
img.nifti_header.set_intent('NIFTI_INTENT_CONNECTIVITY_PARCELLATED_' 'PARCELLATED_SERIES')
475+
img.nifti_header.set_intent('NIFTI_INTENT_CONNECTIVITY_PARCELLATED_PARCELLATED_SERIES')
476476

477477
with InTemporaryDirectory():
478478
ci.save(img, 'test.pconnseries.nii')
@@ -496,7 +496,7 @@ def test_pconnscalar():
496496
hdr = ci.Cifti2Header(matrix)
497497
data = np.random.randn(4, 4, 2)
498498
img = ci.Cifti2Image(data, hdr)
499-
img.nifti_header.set_intent('NIFTI_INTENT_CONNECTIVITY_PARCELLATED_' 'PARCELLATED_SCALAR')
499+
img.nifti_header.set_intent('NIFTI_INTENT_CONNECTIVITY_PARCELLATED_PARCELLATED_SCALAR')
500500

501501
with InTemporaryDirectory():
502502
ci.save(img, 'test.pconnscalar.nii')

Diff for: 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',

Diff for: 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

Diff for: 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

Diff for: nibabel/data.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313

1414
from .environment import get_nipy_system_dir, get_nipy_user_dir
1515

16-
DEFAULT_INSTALL_HINT = (
17-
'If you have the package, have you set the ' 'path to the package correctly?'
18-
)
16+
DEFAULT_INSTALL_HINT = 'If you have the package, have you set the path to the package correctly?'
1917

2018

2119
class DataError(Exception):

Diff for: nibabel/dataobj_images.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def dataobj(self):
4949

5050
@property
5151
@deprecate_with_version(
52-
'_data attribute not part of public API. ' 'please use "dataobj" property instead.',
52+
'_data attribute not part of public API. Please use "dataobj" property instead.',
5353
'2.0',
5454
'4.0',
5555
)

Diff for: nibabel/ecat.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ def __init__(self, dataobj, affine, header, subheader, mlist, extra=None, file_m
826826
def affine(self):
827827
if not self._subheader._check_affines():
828828
warnings.warn(
829-
'Affines different across frames, loading affine ' 'from FIRST frame', UserWarning
829+
'Affines different across frames, loading affine from FIRST frame', UserWarning
830830
)
831831
return self._affine
832832

@@ -908,7 +908,7 @@ def from_file_map(klass, file_map, *, mmap=True, keep_file_open=None):
908908
# Get affine
909909
if not subheaders._check_affines():
910910
warnings.warn(
911-
'Affines different across frames, loading affine ' 'from FIRST frame', UserWarning
911+
'Affines different across frames, loading affine from FIRST frame', UserWarning
912912
)
913913
aff = subheaders.get_frame_affine()
914914
img = klass(data, aff, header, subheaders, mlist, extra=None, file_map=file_map)
@@ -1025,7 +1025,7 @@ def to_file_map(self, file_map=None):
10251025

10261026
@classmethod
10271027
def from_image(klass, img):
1028-
raise NotImplementedError('Ecat images can only be generated ' 'from file objects')
1028+
raise NotImplementedError('Ecat images can only be generated from file objects')
10291029

10301030
@classmethod
10311031
def load(klass, filespec):

Diff for: nibabel/filebasedimages.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def from_header(klass, header=None):
3535
if type(header) == klass:
3636
return header.copy()
3737
raise NotImplementedError(
38-
'Header class requires a conversion ' f'from {klass} to {type(header)}'
38+
f'Header class requires a conversion from {klass} to {type(header)}'
3939
)
4040

4141
@classmethod
@@ -209,7 +209,7 @@ def __getitem__(self, key):
209209
raise TypeError('Cannot slice image objects.')
210210

211211
@deprecate_with_version(
212-
'get_header method is deprecated.\n' 'Please use the ``img.header`` property ' 'instead.',
212+
'get_header method is deprecated.\nPlease use the ``img.header`` property instead.',
213213
'2.1',
214214
'4.0',
215215
)

Diff for: nibabel/filename_parser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def types_filenames(
114114
"""
115115
template_fname = _stringify_path(template_fname)
116116
if not isinstance(template_fname, str):
117-
raise TypesFilenamesError('Need file name as input ' 'to set_filenames')
117+
raise TypesFilenamesError('Need file name as input to set_filenames')
118118
if template_fname.endswith('.'):
119119
template_fname = template_fname[:-1]
120120
filename, found_ext, ignored, guessed_name = parse_filename(

Diff for: nibabel/fileslice.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def canonical_slicers(sliceobj, shape, check_inds=True):
104104
if slicer == Ellipsis:
105105
remaining = sliceobj[i + 1 :]
106106
if Ellipsis in remaining:
107-
raise ValueError('More than one Ellipsis in slicing ' 'expression')
107+
raise ValueError('More than one Ellipsis in slicing expression')
108108
real_remaining = [r for r in remaining if r is not None]
109109
n_ellided = n_dim - n_real - len(real_remaining)
110110
can_slicers.extend((slice(None),) * n_ellided)

Diff for: nibabel/freesurfer/mghformat.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def set_zooms(self, zooms):
313313
raise HeaderDataError('Expecting %d zoom values' % ndims)
314314
if np.any(zooms[:3] <= 0):
315315
raise HeaderDataError(
316-
'Spatial (first three) zooms must be positive; got ' f'{tuple(zooms[:3])}'
316+
f'Spatial (first three) zooms must be positive; got {tuple(zooms[:3])}'
317317
)
318318
hdr['delta'] = zooms[:3]
319319
if len(zooms) == 4:
@@ -475,7 +475,7 @@ def as_byteswapped(self, endianness=None):
475475
476476
"""
477477
if endianness is None or endian_codes[endianness] != '>':
478-
raise ValueError('Cannot byteswap MGHHeader - ' 'must always be big endian')
478+
raise ValueError('Cannot byteswap MGHHeader - must always be big endian')
479479
return self.copy()
480480

481481
@classmethod

0 commit comments

Comments
 (0)