Skip to content

Commit 5161e67

Browse files
STY: Apply ruff/flake8-quotes rule Q000
Q000 Single quotes found but double quotes preferred
1 parent dfbe415 commit 5161e67

23 files changed

+69
-69
lines changed

doc/devel/matlab_example1.py

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

1212
class ConmapTxt2MatInputSpec(BaseInterfaceInputSpec):
1313
in_file = File(exists=True, mandatory=True)
14-
out_file = File('cmatrix.mat', usedefault=True)
14+
out_file = File("cmatrix.mat", usedefault=True)
1515

1616

1717
class ConmapTxt2MatOutputSpec(TraitedSpec):
@@ -48,5 +48,5 @@ def _run_interface(self, runtime):
4848

4949
def _list_outputs(self):
5050
outputs = self._outputs().get()
51-
outputs['out_file'] = os.path.abspath(self.inputs.out_file)
51+
outputs["out_file"] = os.path.abspath(self.inputs.out_file)
5252
return outputs

doc/devel/matlab_example2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
class HelloWorldInputSpec(MatlabInputSpec):
7-
name = traits.Str(mandatory=True, desc='Name of person to say hello to')
7+
name = traits.Str(mandatory=True, desc="Name of person to say hello to")
88

99

1010
class HelloWorldOutputSpec(TraitedSpec):

nipype/interfaces/cmtk/cmtk.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def cmat(
225225
# Add node information from specified parcellation scheme
226226
path, name, ext = split_filename(resolution_network_file)
227227
if ext == ".pck":
228-
with open(resolution_network_file, 'rb') as f:
228+
with open(resolution_network_file, "rb") as f:
229229
gp = pickle.load(f)
230230
elif ext == ".graphml":
231231
gp = nx.read_graphml(resolution_network_file)
@@ -380,7 +380,7 @@ def cmat(
380380
fibdev.add_edge(u, v, weight=di["fiber_length_std"])
381381

382382
iflogger.info("Writing network as %s", matrix_name)
383-
with open(op.abspath(matrix_name), 'wb') as f:
383+
with open(op.abspath(matrix_name), "wb") as f:
384384
pickle.dump(G, f, pickle.HIGHEST_PROTOCOL)
385385

386386
numfib_mlab = nx.to_numpy_array(numfib, dtype=int)
@@ -396,7 +396,7 @@ def cmat(
396396
path, name, ext = split_filename(matrix_name)
397397
intersection_matrix_name = op.abspath(name + "_intersections") + ext
398398
iflogger.info("Writing intersection network as %s", intersection_matrix_name)
399-
with open(intersection_matrix_name, 'wb') as f:
399+
with open(intersection_matrix_name, "wb") as f:
400400
pickle.dump(I, f, pickle.HIGHEST_PROTOCOL)
401401

402402
path, name, ext = split_filename(matrix_mat_name)
@@ -1071,7 +1071,7 @@ def create_nodes(roi_file, resolution_network_file, out_filename):
10711071
)
10721072
)
10731073
G.nodes[int(u)]["dn_position"] = (xyz[0], xyz[2], -xyz[1])
1074-
with open(out_filename, 'wb') as f:
1074+
with open(out_filename, "wb") as f:
10751075
pickle.dump(G, f, pickle.HIGHEST_PROTOCOL)
10761076
return out_filename
10771077

nipype/interfaces/cmtk/convert.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
def _read_pickle(fname):
1919
import pickle
2020

21-
with open(fname, 'rb') as f:
21+
with open(fname, "rb") as f:
2222
return pickle.load(f)
2323

2424

@@ -193,17 +193,17 @@ def _run_interface(self, runtime):
193193
for data in self.inputs.data_files:
194194
_, data_name, _ = split_filename(data)
195195
cda = cf.CData(name=data_name, src=data, fileformat="NumPy")
196-
if 'lengths' in data_name:
196+
if "lengths" in data_name:
197197
cda.dtype = "FinalFiberLengthArray"
198-
if 'endpoints' in data_name:
198+
if "endpoints" in data_name:
199199
cda.dtype = "FiberEndpoints"
200-
if 'labels' in data_name:
200+
if "labels" in data_name:
201201
cda.dtype = "FinalFiberLabels"
202202
a.add_connectome_data(cda)
203203

204204
a.print_summary()
205205
_, name, ext = split_filename(self.inputs.out_file)
206-
if ext != '.cff':
206+
if ext != ".cff":
207207
ext = ".cff"
208208
cf.save_to_cff(a, op.abspath(name + ext))
209209

@@ -212,7 +212,7 @@ def _run_interface(self, runtime):
212212
def _list_outputs(self):
213213
outputs = self._outputs().get()
214214
_, name, ext = split_filename(self.inputs.out_file)
215-
if ext != '.cff':
215+
if ext != ".cff":
216216
ext = ".cff"
217217
outputs["connectome_file"] = op.abspath(name + ext)
218218
return outputs
@@ -280,7 +280,7 @@ def _run_interface(self, runtime):
280280
metadata.set_email("My Email")
281281

282282
_, name, ext = split_filename(self.inputs.out_file)
283-
if ext != '.cff':
283+
if ext != ".cff":
284284
ext = ".cff"
285285
cf.save_to_cff(newcon, op.abspath(name + ext))
286286

@@ -289,7 +289,7 @@ def _run_interface(self, runtime):
289289
def _list_outputs(self):
290290
outputs = self._outputs().get()
291291
_, name, ext = split_filename(self.inputs.out_file)
292-
if ext != '.cff':
292+
if ext != ".cff":
293293
ext = ".cff"
294294
outputs["connectome_file"] = op.abspath(name + ext)
295295
return outputs

nipype/interfaces/cmtk/nbs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424

2525
def _read_pickle(fname):
26-
with open(fname, 'rb') as f:
26+
with open(fname, "rb") as f:
2727
return pickle.load(f)
2828

2929

@@ -174,13 +174,13 @@ def _run_interface(self, runtime):
174174

175175
path = op.abspath("NBS_Result_" + details)
176176
iflogger.info(path)
177-
with open(path, 'wb') as f:
177+
with open(path, "wb") as f:
178178
pickle.dump(nbsgraph, f, pickle.HIGHEST_PROTOCOL)
179179
iflogger.info("Saving output NBS edge network as %s", path)
180180

181181
pval_path = op.abspath("NBS_P_vals_" + details)
182182
iflogger.info(pval_path)
183-
with open(pval_path, 'wb') as f:
183+
with open(pval_path, "wb") as f:
184184
pickle.dump(nbs_pval_graph, f, pickle.HIGHEST_PROTOCOL)
185185
iflogger.info("Saving output p-value network as %s", pval_path)
186186
return runtime

nipype/interfaces/cmtk/nx.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424

2525
def _read_pickle(fname):
26-
with open(fname, 'rb') as f:
26+
with open(fname, "rb") as f:
2727
return pickle.load(f)
2828

2929

@@ -203,7 +203,7 @@ def average_networks(in_files, ntwk_res_file, group_id):
203203

204204
# Writes the networks and returns the name
205205
network_name = group_id + "_average.pck"
206-
with open(op.abspath(network_name), 'wb') as f:
206+
with open(op.abspath(network_name), "wb") as f:
207207
pickle.dump(avg_ntwk, f, pickle.HIGHEST_PROTOCOL)
208208
iflogger.info("Saving average network as %s", op.abspath(network_name))
209209
avg_ntwk = fix_keys_for_gexf(avg_ntwk)
@@ -487,7 +487,7 @@ def _run_interface(self, runtime):
487487
for key in list(node_measures.keys()):
488488
newntwk = add_node_data(node_measures[key], ntwk)
489489
out_file = op.abspath(self._gen_outfilename(key, "pck"))
490-
with open(out_file, 'wb') as f:
490+
with open(out_file, "wb") as f:
491491
pickle.dump(newntwk, f, pickle.HIGHEST_PROTOCOL)
492492
nodentwks.append(out_file)
493493
if isdefined(self.inputs.out_node_metrics_matlab):
@@ -502,7 +502,7 @@ def _run_interface(self, runtime):
502502
for key in list(edge_measures.keys()):
503503
newntwk = add_edge_data(edge_measures[key], ntwk)
504504
out_file = op.abspath(self._gen_outfilename(key, "pck"))
505-
with open(out_file, 'wb') as f:
505+
with open(out_file, "wb") as f:
506506
pickle.dump(newntwk, f, pickle.HIGHEST_PROTOCOL)
507507
edgentwks.append(out_file)
508508
if isdefined(self.inputs.out_edge_metrics_matlab):
@@ -527,7 +527,7 @@ def _run_interface(self, runtime):
527527
out_file = op.abspath(
528528
self._gen_outfilename(self.inputs.out_k_crust, "pck")
529529
)
530-
with open(out_file, 'wb') as f:
530+
with open(out_file, "wb") as f:
531531
pickle.dump(ntwk_measures[key], f, pickle.HIGHEST_PROTOCOL)
532532
kntwks.append(out_file)
533533
gpickled.extend(kntwks)

nipype/interfaces/cmtk/tests/test_nbs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def creating_graphs(tmpdir):
2121
G = nx.from_numpy_array(graph)
2222
out_file = tmpdir.strpath + graphnames[idx] + ".pck"
2323
# Save as pck file
24-
with open(out_file, 'wb') as f:
24+
with open(out_file, "wb") as f:
2525
pickle.dump(G, f, pickle.HIGHEST_PROTOCOL)
2626
graphlist.append(out_file)
2727
return graphlist

nipype/interfaces/dipy/tests/test_base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,19 @@ def test_get_default_args():
124124
def test(dummy=11, x=3):
125125
return dummy, x
126126

127-
@deprecated_params('x', None, '0.3', '0.5', alternative='test2.y')
127+
@deprecated_params("x", None, "0.3", "0.5", alternative="test2.y")
128128
def test2(dummy=11, x=3):
129129
return dummy, x
130130

131-
@deprecated_params(['dummy', 'x'], None, '0.3', alternative='test2.y')
131+
@deprecated_params(["dummy", "x"], None, "0.3", alternative="test2.y")
132132
def test3(dummy=11, x=3):
133133
return dummy, x
134134

135-
@deprecated_params(['dummy', 'x'], None, '0.3', '0.5', alternative='test2.y')
135+
@deprecated_params(["dummy", "x"], None, "0.3", "0.5", alternative="test2.y")
136136
def test4(dummy=11, x=3):
137137
return dummy, x
138138

139-
expected_res = {'dummy': 11, 'x': 3}
139+
expected_res = {"dummy": 11, "x": 3}
140140
for func in [test, test2, test3, test4]:
141141
assert get_default_args(func) == expected_res
142142

nipype/interfaces/freesurfer/model.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,9 @@ class GLMFitInputSpec(FSTraitedSpec):
451451
sim_done_file = File(
452452
argstr="--sim-done %s", desc="create file when simulation finished"
453453
)
454-
_ext_xor = ['nii', 'nii_gz']
455-
nii = traits.Bool(argstr='--nii', desc='save outputs as nii', xor=_ext_xor)
456-
nii_gz = traits.Bool(argstr='--nii.gz', desc='save outputs as nii.gz', xor=_ext_xor)
454+
_ext_xor = ["nii", "nii_gz"]
455+
nii = traits.Bool(argstr="--nii", desc="save outputs as nii", xor=_ext_xor)
456+
nii_gz = traits.Bool(argstr="--nii.gz", desc="save outputs as nii.gz", xor=_ext_xor)
457457

458458

459459
class GLMFitOutputSpec(TraitedSpec):
@@ -511,11 +511,11 @@ def _list_outputs(self):
511511
outputs["glm_dir"] = glmdir
512512

513513
if isdefined(self.inputs.nii_gz):
514-
ext = 'nii.gz'
514+
ext = "nii.gz"
515515
elif isdefined(self.inputs.nii):
516-
ext = 'nii'
516+
ext = "nii"
517517
else:
518-
ext = 'mgh'
518+
ext = "mgh"
519519

520520
# Assign the output files that always get created
521521
outputs["beta_file"] = os.path.join(glmdir, f"beta.{ext}")

nipype/interfaces/freesurfer/petsurfer.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ class GTMSeg(FSCommand):
125125

126126
def _list_outputs(self):
127127
outputs = self.output_spec().get()
128-
outputs['out_file'] = os.path.join(
128+
outputs["out_file"] = os.path.join(
129129
self.inputs.subjects_dir,
130130
self.inputs.subject_id,
131-
'mri',
131+
"mri",
132132
self.inputs.out_file,
133133
)
134134
return outputs
@@ -516,7 +516,7 @@ class GTMPVC(FSCommand):
516516
def _format_arg(self, name, spec, val):
517517
# Values taken from
518518
# https://github.com/freesurfer/freesurfer/blob/fs-7.2/mri_gtmpvc/mri_gtmpvc.cpp#L115-L122
519-
if name == 'optimization_schema':
519+
if name == "optimization_schema":
520520
return (
521521
spec.argstr
522522
% {
@@ -530,8 +530,8 @@ def _format_arg(self, name, spec, val):
530530
"MB3": 8,
531531
}[val]
532532
)
533-
if name == 'mg':
534-
return spec.argstr % (val[0], ' '.join(val[1]))
533+
if name == "mg":
534+
return spec.argstr % (val[0], " ".join(val[1]))
535535
return super()._format_arg(name, spec, val)
536536

537537
def _list_outputs(self):

nipype/interfaces/freesurfer/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1967,7 +1967,7 @@ def _format_arg(self, name, spec, value):
19671967
if name == "lta_in" and self.inputs.invert_lta_in:
19681968
spec = "--lta-inv %s"
19691969
if name in ("fsl_out", "lta_out") and value is True:
1970-
value = self._list_outputs()[f'{name[:3]}_file']
1970+
value = self._list_outputs()[f"{name[:3]}_file"]
19711971
return super()._format_arg(name, spec, value)
19721972

19731973
def _list_outputs(self):

nipype/interfaces/fsl/model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -820,9 +820,9 @@ class FILMGLS(FSLCommand):
820820
def __init__(self, **inputs):
821821
super(FILMGLS, self).__init__(**inputs)
822822
if Info.version() and LooseVersion(Info.version()) > LooseVersion("5.0.6"):
823-
if 'output_type' not in inputs:
824-
if isdefined(self.inputs.mode) and self.inputs.mode == 'surface':
825-
self.inputs.output_type = 'GIFTI'
823+
if "output_type" not in inputs:
824+
if isdefined(self.inputs.mode) and self.inputs.mode == "surface":
825+
self.inputs.output_type = "GIFTI"
826826

827827
def _get_pe_files(self, cwd):
828828
files = None

nipype/interfaces/nilearn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def _process_inputs(self):
152152
if self.inputs.include_global:
153153
global_label_data = label_data.dataobj.sum(axis=3) # sum across all regions
154154
global_label_data = (
155-
np.rint(global_label_data).clip(0, 1).astype('u1')
155+
np.rint(global_label_data).clip(0, 1).astype("u1")
156156
) # binarize
157157
global_label_data = self._4d(global_label_data, label_data.affine)
158158
global_masker = nl.NiftiLabelsMasker(

nipype/interfaces/robex/preprocess.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class RobexInputSpec(CommandLineInputSpec):
1616
position=1,
1717
argstr="%s",
1818
hash_files=False,
19-
name_template='%s_brain',
19+
name_template="%s_brain",
2020
name_source=["in_file"],
2121
keep_extension=True,
2222
)
@@ -25,7 +25,7 @@ class RobexInputSpec(CommandLineInputSpec):
2525
position=2,
2626
argstr="%s",
2727
hash_files=False,
28-
name_template='%s_brainmask',
28+
name_template="%s_brainmask",
2929
name_source=["in_file"],
3030
keep_extension=True,
3131
)
@@ -61,4 +61,4 @@ class RobexSegment(CommandLine):
6161

6262
input_spec = RobexInputSpec
6363
output_spec = RobexOutputSpec
64-
_cmd = 'runROBEX.sh'
64+
_cmd = "runROBEX.sh"

nipype/interfaces/spm/model.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,17 +350,17 @@ def _list_outputs(self):
350350

351351
if contrast:
352352
outputs["con_images"] = [
353-
os.path.join(pth, cont) for cont in contrast if 'con' in cont
353+
os.path.join(pth, cont) for cont in contrast if "con" in cont
354354
]
355355
outputs["ess_images"] = [
356-
os.path.join(pth, cont) for cont in contrast if 'ess' in cont
356+
os.path.join(pth, cont) for cont in contrast if "ess" in cont
357357
]
358358
if contrast_spm:
359359
outputs["spmT_images"] = [
360-
os.path.join(pth, cont) for cont in contrast_spm if 'spmT' in cont
360+
os.path.join(pth, cont) for cont in contrast_spm if "spmT" in cont
361361
]
362362
outputs["spmF_images"] = [
363-
os.path.join(pth, cont) for cont in contrast_spm if 'spmF' in cont
363+
os.path.join(pth, cont) for cont in contrast_spm if "spmF" in cont
364364
]
365365

366366
outputs["mask_image"] = os.path.join(pth, f"mask.{outtype}")

nipype/interfaces/spm/preprocess.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,11 +334,11 @@ class ApplyVDM(SPMCommand):
334334
def _format_arg(self, opt, spec, val):
335335
"""Convert input to appropriate format for spm"""
336336

337-
if opt == 'in_files':
337+
if opt == "in_files":
338338
return scans_for_fnames(
339339
ensure_list(val), keep4d=False, separate_sessions=False
340340
)
341-
if opt == 'vdmfile':
341+
if opt == "vdmfile":
342342
return scans_for_fname(ensure_list(val))
343343
return super()._format_arg(opt, spec, val)
344344

nipype/interfaces/tests/test_io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ def _mock_get_ssh_client(self):
707707

708708
def test_ExportFile(tmp_path):
709709
test_in = tmp_path / "in.txt"
710-
test_in.write_text("test string", encoding='utf-8')
710+
test_in.write_text("test string", encoding="utf-8")
711711
i = nio.ExportFile()
712712
i.inputs.in_file = str(test_in)
713713
i.inputs.out_file = str(tmp_path / "out.tsv")

nipype/pipeline/engine/nodes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -755,10 +755,10 @@ def _tab(text):
755755

756756
if not text:
757757
return ""
758-
return indent(text, '\t')
758+
return indent(text, "\t")
759759

760760
msg = f"Exception raised while executing Node {self.name}.\n\n"
761-
if hasattr(runtime, 'cmdline'):
761+
if hasattr(runtime, "cmdline"):
762762
msg += (
763763
f"Cmdline:\n{_tab(runtime.cmdline)}\n"
764764
f"Stdout:\n{_tab(runtime.stdout)}\n"

0 commit comments

Comments
 (0)