Skip to content

Commit 306689f

Browse files
STY: Further simplification
Co-authored-by: Chris Markiewicz <[email protected]>
1 parent a2681fa commit 306689f

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

nipype/interfaces/afni/utils.py

+1-1
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})
237+
outputs.trait_set(**{k: int(v) for k, v in d.items()})
238238
return outputs
239239

240240

nipype/interfaces/cmtk/convert.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,11 @@ def _run_interface(self, runtime):
194194
for data in self.inputs.data_files:
195195
_, data_name, _ = split_filename(data)
196196
cda = cf.CData(name=data_name, src=data, fileformat="NumPy")
197-
if string.find(data_name, 'lengths') != -1:
197+
if 'lengths' in data_name:
198198
cda.dtype = "FinalFiberLengthArray"
199-
if string.find(data_name, 'endpoints') != -1:
199+
if 'endpoints' in data_name:
200200
cda.dtype = "FiberEndpoints"
201-
if string.find(data_name, 'labels') != -1:
201+
if 'labels' in data_name:
202202
cda.dtype = "FinalFiberLabels"
203203
a.add_connectome_data(cda)
204204

nipype/interfaces/cmtk/nx.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def average_networks(in_files, ntwk_res_file, group_id):
166166
for edge in edges:
167167
data = ntwk.edge[edge[0]][edge[1]]
168168
if ntwk.edge[edge[0]][edge[1]]["count"] >= count_to_keep_edge:
169-
for key in list(data.keys()):
169+
for key in data:
170170
if key != "count":
171171
data[key] = data[key] / len(in_files)
172172
ntwk.edge[edge[0]][edge[1]] = data
@@ -183,7 +183,7 @@ def average_networks(in_files, ntwk_res_file, group_id):
183183
avg_edges = avg_ntwk.edges()
184184
for edge in avg_edges:
185185
data = avg_ntwk.edge[edge[0]][edge[1]]
186-
for key in list(data.keys()):
186+
for key in data:
187187
if key != "count":
188188
edge_dict[key] = np.zeros(
189189
(avg_ntwk.number_of_nodes(), avg_ntwk.number_of_nodes())

nipype/interfaces/slicer/generate_classes.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ def force_to_valid_python_variable_name(old_name):
3333

3434
def add_class_to_package(class_codes, class_names, module_name, package_dir):
3535
module_python_filename = os.path.join(package_dir, "%s.py" % module_name)
36-
with (
37-
open(module_python_filename, "w") as f_m,
38-
open(os.path.join(package_dir, "__init__.py"), "a+") as f_i,
39-
):
36+
with open(module_python_filename, "w") as f_m:
4037
f_m.write(
4138
"""# -*- coding: utf-8 -*-
4239
\"\"\"Autogenerated file - DO NOT EDIT
@@ -48,6 +45,7 @@ def add_class_to_package(class_codes, class_names, module_name, package_dir):
4845
import os\n\n\n"""
4946
f_m.write(imports)
5047
f_m.write("\n\n".join(class_codes))
48+
with open(os.path.join(package_dir, "__init__.py"), "a+") as f_i:
5149
f_i.write("from {} import {}\n".format(module_name, ", ".join(class_names)))
5250

5351

0 commit comments

Comments
 (0)