Skip to content

Commit 300ae9d

Browse files
committed
STY: pyupgrade --py38-plus
1 parent b1ca471 commit 300ae9d

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

nitransforms/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def cli_apply(pargs):
4545
cval=pargs.cval,
4646
prefilter=pargs.prefilter,
4747
)
48-
moved.to_filename(pargs.out or "nt_{}".format(os.path.basename(pargs.moving)))
48+
moved.to_filename(pargs.out or f"nt_{os.path.basename(pargs.moving)}")
4949

5050

5151
def get_parser():

nitransforms/io/lta.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def set_type(self, new_type):
176176
return
177177

178178
raise NotImplementedError(
179-
"Converting {0} to {1} is not yet available".format(
179+
"Converting {} to {} is not yet available".format(
180180
transform_codes.label[current], transform_codes.label[new_type]
181181
)
182182
)
@@ -334,7 +334,7 @@ def to_string(self):
334334
code = int(self["type"])
335335
header = [
336336
"# LTA-array file created by NiTransforms",
337-
"type = {} # {}".format(code, transform_codes.label[code]),
337+
f"type = {code} # {transform_codes.label[code]}",
338338
"nxforms = {}".format(self["nxforms"]),
339339
]
340340
xforms = [xfm.to_string(partial=True) for xfm in self._xforms]

nitransforms/nonlinear.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ class BSplineFieldTransform(TransformBase):
241241

242242
def __init__(self, coefficients, reference=None, order=3):
243243
"""Create a smooth deformation field using B-Spline basis."""
244-
super(BSplineFieldTransform, self).__init__()
244+
super().__init__()
245245
self._order = order
246246

247247
coefficients = _ensure_image(coefficients)

nitransforms/tests/test_io.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def test_Linear_common(tmpdir, data_path, sw, image_orientation, get_testdata):
204204
with pytest.raises(TransformFileError):
205205
factory.from_string("")
206206

207-
fname = "affine-%s.%s%s" % (image_orientation, sw, ext)
207+
fname = f"affine-{image_orientation}.{sw}{ext}"
208208

209209
# Test the transform loaders are implemented
210210
xfm = factory.from_filename(data_path / fname)
@@ -262,7 +262,7 @@ def test_LinearList_common(tmpdir, data_path, sw, image_orientation, get_testdat
262262

263263
tflist1 = factory(mats)
264264

265-
fname = "affine-%s.%s%s" % (image_orientation, sw, ext)
265+
fname = f"affine-{image_orientation}.{sw}{ext}"
266266

267267
with pytest.raises(FileNotFoundError):
268268
factory.from_filename(fname)
@@ -305,7 +305,7 @@ def test_ITKLinearTransform(tmpdir, testdata_path):
305305

306306
# Test to_filename(textfiles)
307307
itkxfm.to_filename("textfile.tfm")
308-
with open("textfile.tfm", "r") as f:
308+
with open("textfile.tfm") as f:
309309
itkxfm2 = itk.ITKLinearTransform.from_fileobj(f)
310310
assert np.allclose(itkxfm["parameters"], itkxfm2["parameters"])
311311

nitransforms/tests/test_linear.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def test_linear_save(tmpdir, data_path, get_testdata, image_orientation, sw_tool
226226
elif sw_tool == "fs":
227227
ext = ".lta"
228228

229-
xfm_fname1 = "M.%s%s" % (sw_tool, ext)
229+
xfm_fname1 = f"M.{sw_tool}{ext}"
230230
xfm.to_filename(xfm_fname1, fmt=sw_tool)
231231

232232
xfm_fname2 = str(data_path / "affine-%s.%s%s") % (image_orientation, sw_tool, ext)
@@ -257,7 +257,7 @@ def test_apply_linear_transform(tmpdir, get_testdata, get_testmask, image_orient
257257
msk.to_filename("mask.nii.gz")
258258

259259
# Write out transform file (software-dependent)
260-
xfm_fname = "M.%s%s" % (sw_tool, ext)
260+
xfm_fname = f"M.{sw_tool}{ext}"
261261
# Change reference dataset for AFNI & oblique
262262
if (sw_tool, image_orientation) == ("afni", "oblique"):
263263
io.afni.AFNILinearTransform.from_ras(
@@ -278,7 +278,7 @@ def test_apply_linear_transform(tmpdir, get_testdata, get_testmask, image_orient
278278
# skip test if command is not available on host
279279
exe = cmd.split(" ", 1)[0]
280280
if not shutil.which(exe):
281-
pytest.skip("Command {} not found on host".format(exe))
281+
pytest.skip(f"Command {exe} not found on host")
282282

283283
# resample mask
284284
exit_code = check_call([cmd], shell=True)

nitransforms/tests/test_nonlinear.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def test_displacements_field1(
158158
# skip test if command is not available on host
159159
exe = cmd.split(" ", 1)[0]
160160
if not shutil.which(exe):
161-
pytest.skip("Command {} not found on host".format(exe))
161+
pytest.skip(f"Command {exe} not found on host")
162162

163163
# resample mask
164164
exit_code = check_call([cmd], shell=True)
@@ -219,7 +219,7 @@ def test_displacements_field2(tmp_path, testdata_path, sw_tool):
219219
# skip test if command is not available on host
220220
exe = cmd.split(" ", 1)[0]
221221
if not shutil.which(exe):
222-
pytest.skip("Command {} not found on host".format(exe))
222+
pytest.skip(f"Command {exe} not found on host")
223223

224224
exit_code = check_call([cmd], shell=True)
225225
assert exit_code == 0

0 commit comments

Comments
 (0)