Skip to content

Commit 7689ea8

Browse files
jond01effigies
andauthored
STY: Apply suggestions from code review
Co-authored-by: Chris Markiewicz <[email protected]>
1 parent 42fb61d commit 7689ea8

File tree

8 files changed

+11
-19
lines changed

8 files changed

+11
-19
lines changed

nibabel/arrayproxy.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,7 @@ def reshape(self, shape):
412412
shape = tuple(unknown_size if e == -1 else e for e in shape)
413413

414414
if np.prod(shape) != size:
415-
raise ValueError(f"cannot reshape array of size {size:d} "
416-
f"into shape {shape!s}")
415+
raise ValueError(f"cannot reshape array of size {size:d} into shape {shape!s}")
417416
return self.__class__(file_like=self.file_like,
418417
spec=(shape, self._dtype, self._offset,
419418
self._slope, self._inter),

nibabel/streamlines/array_sequence.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,7 @@ def __setitem__(self, idx, elements):
438438

439439
if is_array_sequence(elements):
440440
if len(lengths) != len(elements):
441-
msg = (f"Trying to set {len(lengths)} sequences with "
442-
f"{len(elements)} sequences.")
441+
msg = f"Trying to set {len(lengths)} sequences with {len(elements)} sequences."
443442
raise ValueError(msg)
444443

445444
if sum(lengths) != elements.total_nb_rows:

nibabel/streamlines/tck.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,8 @@ def _read_header(fileobj):
340340
hdr['file'] = f'. {offset_data}'
341341

342342
if hdr['file'].split()[0] != '.':
343-
msg = (f"TCK only supports single-file - in other words the"
344-
f" filename part must be specified as '.' but "
345-
f"'{hdr['file'].split()[0]}' was specified.")
343+
msg = ("TCK only supports single-file - in other words the filename part must be "
344+
f"specified as '.' but '{hdr['file'].split()[0]}' was specified.")
346345
raise HeaderError("Missing 'file' attribute in TCK header.")
347346

348347
# Set endianness and _dtype attributes in the header.
@@ -453,6 +452,5 @@ def __str__(self):
453452
info = ""
454453
info += f"\nMAGIC NUMBER: {hdr[Field.MAGIC_NUMBER]}"
455454
info += "\n"
456-
info += "\n".join([f"{k}: {v}"
457-
for k, v in hdr.items() if not k.startswith('_')])
455+
info += "\n".join(f"{k}: {v}" for k, v in hdr.items() if not k.startswith('_'))
458456
return info

nibabel/streamlines/tractogram.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,7 @@ def __setitem__(self, key, value):
168168

169169
# We make sure there is the right amount of data.
170170
if 0 < self.n_rows != value.total_nb_rows:
171-
msg = (f"The number of values ({value.total_nb_rows}) "
172-
f"should match ({self.n_rows}).")
171+
msg = f"The number of values ({value.total_nb_rows}) should match ({self.n_rows})."
173172
raise ValueError(msg)
174173

175174
self.store[key] = value

nibabel/streamlines/trk.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ def encode_value_in_name(value, name, max_name_len=20):
153153
`value`, padded with ``\x00`` bytes.
154154
"""
155155
if len(name) > max_name_len:
156-
msg = (f"Data information named '{name}' is too long"
157-
f" (max {max_name_len} characters.)")
156+
msg = f"Data information named '{name}' is too long (max {max_name_len} characters.)"
158157
raise ValueError(msg)
159158
encoded_name = name if value <= 1 else name + '\x00' + str(value)
160159
if len(encoded_name) > max_name_len:

nibabel/tests/data/check_parrec_reslice.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ def gmean_norm(data):
6161
normal_data = normal_img.get_fdata()
6262
normal_normed = gmean_norm(normal_data)
6363

64-
print(f"RMS of standard image {normal_fname:<44}: "
65-
f"{np.sqrt(np.sum(normal_normed ** 2))}")
64+
print(f"RMS of standard image {normal_fname:<44}: {np.sqrt(np.sum(normal_normed ** 2))}")
6665

6766
for parfile in glob.glob("*.PAR"):
6867
if parfile == normal_fname:

nibabel/tests/test_deprecator.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ def test_dep_func(self):
9494
assert func() is None
9595
assert len(w) == 1
9696
assert (func.__doc__ ==
97-
f'foo\n\n* Will raise {ExpiredDeprecationError} '
98-
'as of version: 99.4\n')
97+
f'foo\n\n* Will raise {ExpiredDeprecationError} as of version: 99.4\n')
9998
func = dec('foo', until='1.8')(func_no_doc)
10099
with pytest.raises(ExpiredDeprecationError):
101100
func()

nibabel/tests/test_volumeutils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,8 +1224,8 @@ def read(self, n_bytes):
12241224
array_from_file(shape, np.int8, NoStringIO())
12251225
except IOError as err:
12261226
message = str(err)
1227-
assert message == (f"Expected {11390625000000000000} bytes, got {0} "
1228-
f"bytes from {'object'}\n - could the file be damaged?")
1227+
assert message == ("Expected 11390625000000000000 bytes, got 0 "
1228+
"bytes from object\n - could the file be damaged?")
12291229

12301230

12311231
def test__ftype4scaled_finite_warningfilters():

0 commit comments

Comments
 (0)