Skip to content

Commit 303a0e8

Browse files
authored
Merge branch 'master' into replace_imghdr
2 parents 9d401e4 + ccec546 commit 303a0e8

Some content is hidden

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

57 files changed

+252
-261
lines changed

nipype/algorithms/misc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ def _run_interface(self, runtime):
684684

685685
output_array = merge_csvs(self.inputs.in_files)
686686
_, name, ext = split_filename(self.inputs.out_file)
687-
if not ext == ".csv":
687+
if ext != ".csv":
688688
ext = ".csv"
689689

690690
out_file = op.abspath(name + ext)
@@ -725,7 +725,7 @@ def _run_interface(self, runtime):
725725
def _list_outputs(self):
726726
outputs = self.output_spec().get()
727727
_, name, ext = split_filename(self.inputs.out_file)
728-
if not ext == ".csv":
728+
if ext != ".csv":
729729
ext = ".csv"
730730
out_file = op.abspath(name + ext)
731731
outputs["csv_file"] = out_file
@@ -771,7 +771,7 @@ class AddCSVColumn(BaseInterface):
771771
def _run_interface(self, runtime):
772772
in_file = open(self.inputs.in_file)
773773
_, name, ext = split_filename(self.inputs.out_file)
774-
if not ext == ".csv":
774+
if ext != ".csv":
775775
ext = ".csv"
776776
out_file = op.abspath(name + ext)
777777

@@ -791,7 +791,7 @@ def _run_interface(self, runtime):
791791
def _list_outputs(self):
792792
outputs = self.output_spec().get()
793793
_, name, ext = split_filename(self.inputs.out_file)
794-
if not ext == ".csv":
794+
if ext != ".csv":
795795
ext = ".csv"
796796
out_file = op.abspath(name + ext)
797797
outputs["csv_file"] = out_file

nipype/algorithms/modelgen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def bids_gen_info(
161161
for bids_event_file in bids_event_files:
162162
with open(bids_event_file) as f:
163163
f_events = csv.DictReader(f, skipinitialspace=True, delimiter="\t")
164-
events = [{k: v for k, v in row.items()} for row in f_events]
164+
events = list(f_events)
165165
if not condition_column:
166166
condition_column = "_trial_type"
167167
for i in events:

nipype/algorithms/tests/test_CompCor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,9 @@ def run_cc(
287287
components_metadata = [
288288
line.rstrip().split("\t") for line in metadata_file
289289
]
290-
components_metadata = {
291-
i: j for i, j in zip(components_metadata[0], components_metadata[1])
292-
}
290+
components_metadata = dict(
291+
zip(components_metadata[0], components_metadata[1])
292+
)
293293
assert components_metadata == expected_metadata
294294

295295
return ccresult

nipype/algorithms/tests/test_modelgen.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def test_modelgen_spm_concat(tmpdir):
122122
s = SpecifySPMModel()
123123
s.inputs.input_units = "secs"
124124
s.inputs.concatenate_runs = True
125-
setattr(s.inputs, "output_units", "secs")
125+
s.inputs.output_units = "secs"
126126
assert s.inputs.output_units == "secs"
127127
s.inputs.functional_runs = [filename1, filename2]
128128
s.inputs.time_repetition = 6
@@ -147,7 +147,7 @@ def test_modelgen_spm_concat(tmpdir):
147147
)
148148

149149
# Test case of scans as output units instead of seconds
150-
setattr(s.inputs, "output_units", "scans")
150+
s.inputs.output_units = "scans"
151151
assert s.inputs.output_units == "scans"
152152
s.inputs.subject_info = deepcopy(info)
153153
res = s.run()

nipype/interfaces/afni/base.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,4 @@ def _cmd_prefix(self):
326326

327327
def no_afni():
328328
"""Check whether AFNI is not available."""
329-
if Info.version() is None:
330-
return True
331-
return False
329+
return Info.version() is None

nipype/interfaces/afni/model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ def _parse_inputs(self, skip=None):
636636
def _list_outputs(self):
637637
outputs = self.output_spec().get()
638638

639-
for key in outputs.keys():
639+
for key in outputs:
640640
if isdefined(self.inputs.get()[key]):
641641
outputs[key] = os.path.abspath(self.inputs.get()[key])
642642

@@ -722,7 +722,7 @@ class Synthesize(AFNICommand):
722722
def _list_outputs(self):
723723
outputs = self.output_spec().get()
724724

725-
for key in outputs.keys():
725+
for key in outputs:
726726
if isdefined(self.inputs.get()[key]):
727727
outputs[key] = os.path.abspath(self.inputs.get()[key])
728728

nipype/interfaces/afni/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def aggregate_outputs(self, runtime=None, needed_outputs=None):
234234
m = re.search(pattern, line)
235235
if m:
236236
d = m.groupdict()
237-
outputs.trait_set(**{k: int(d[k]) for k in d.keys()})
237+
outputs.trait_set(**{k: int(v) for k, v in d.items()})
238238
return outputs
239239

240240

@@ -3244,11 +3244,11 @@ def _run_interface(self, runtime):
32443244
for line in runtime.stdout.split("\n")
32453245
if line.strip().startswith("GCOR = ")
32463246
][-1]
3247-
setattr(self, "_gcor", float(gcor_line[len("GCOR = ") :]))
3247+
self._gcor = float(gcor_line[len("GCOR = ") :])
32483248
return runtime
32493249

32503250
def _list_outputs(self):
3251-
return {"out": getattr(self, "_gcor")}
3251+
return {"out": self._gcor}
32523252

32533253

32543254
class AxializeInputSpec(AFNICommandInputSpec):

nipype/interfaces/ants/segmentation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def _format_arg(self, opt, spec, val):
194194
priors_paths[0] % i for i in range(1, n_classes + 1)
195195
]
196196

197-
if not all([os.path.exists(p) for p in priors_paths]):
197+
if not all(os.path.exists(p) for p in priors_paths):
198198
raise FileNotFoundError(
199199
"One or more prior images do not exist: "
200200
"%s." % ", ".join(priors_paths)

nipype/interfaces/ants/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ def _format_arg(self, opt, spec, val):
536536
return super()._format_arg(opt, spec, val)
537537

538538
def _list_outputs(self):
539-
return getattr(self, "_output")
539+
return self._output
540540

541541

542542
class AverageAffineTransformInputSpec(ANTSCommandInputSpec):

nipype/interfaces/base/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ def load_inputs_from_json(self, json_file, overwrite=True):
486486
if not overwrite:
487487
def_inputs = list(self.inputs.get_traitsfree().keys())
488488

489-
new_inputs = list(set(list(inputs_dict.keys())) - set(def_inputs))
489+
new_inputs = set(inputs_dict) - set(def_inputs)
490490
for key in new_inputs:
491491
if hasattr(self.inputs, key):
492492
setattr(self.inputs, key, inputs_dict[key])

0 commit comments

Comments
 (0)