Skip to content

Commit d557f71

Browse files
STY: Apply ruff/flake8-simplify rule SIM201
SIM201 Use `... != ...` instead of `not ... == ...`
1 parent 697297b commit d557f71

File tree

8 files changed

+26
-26
lines changed

8 files changed

+26
-26
lines changed

Diff for: nipype/algorithms/misc.py

+4-4
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

Diff for: nipype/interfaces/cmtk/cmtk.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def get_rois_crossed(pointsmm, roiData, voxelSize):
7777
x = int(pointsmm[j, 0] / float(voxelSize[0]))
7878
y = int(pointsmm[j, 1] / float(voxelSize[1]))
7979
z = int(pointsmm[j, 2] / float(voxelSize[2]))
80-
if not roiData[x, y, z] == 0:
80+
if roiData[x, y, z] != 0:
8181
rois_crossed.append(roiData[x, y, z])
8282
rois_crossed = list(
8383
dict.fromkeys(rois_crossed).keys()
@@ -91,7 +91,7 @@ def get_connectivity_matrix(n_rois, list_of_roi_crossed_lists):
9191
for idx_i, roi_i in enumerate(rois_crossed):
9292
for idx_j, roi_j in enumerate(rois_crossed):
9393
if idx_i > idx_j:
94-
if not roi_i == roi_j:
94+
if roi_i != roi_j:
9595
connectivity_matrix[roi_i - 1, roi_j - 1] += 1
9696
connectivity_matrix = connectivity_matrix + connectivity_matrix.T
9797
return connectivity_matrix
@@ -371,7 +371,7 @@ def cmat(
371371
di["fiber_length_mean"] = 0
372372
di["fiber_length_median"] = 0
373373
di["fiber_length_std"] = 0
374-
if not u == v: # Fix for self loop problem
374+
if u != v: # Fix for self loop problem
375375
G.add_edge(u, v, **di)
376376
if "fiblist" in d:
377377
numfib.add_edge(u, v, weight=di["number_of_fibers"])
@@ -400,7 +400,7 @@ def cmat(
400400
pickle.dump(I, f, pickle.HIGHEST_PROTOCOL)
401401

402402
path, name, ext = split_filename(matrix_mat_name)
403-
if not ext == ".mat":
403+
if ext != ".mat":
404404
ext = ".mat"
405405
matrix_mat_name = matrix_mat_name + ext
406406

@@ -608,7 +608,7 @@ def _run_interface(self, runtime):
608608

609609
matrix_mat_file = op.abspath(self.inputs.out_matrix_mat_file)
610610
path, name, ext = split_filename(matrix_mat_file)
611-
if not ext == ".mat":
611+
if ext != ".mat":
612612
ext = ".mat"
613613
matrix_mat_file = matrix_mat_file + ext
614614

@@ -673,7 +673,7 @@ def _list_outputs(self):
673673

674674
matrix_mat_file = op.abspath(self.inputs.out_matrix_mat_file)
675675
path, name, ext = split_filename(matrix_mat_file)
676-
if not ext == ".mat":
676+
if ext != ".mat":
677677
ext = ".mat"
678678
matrix_mat_file = matrix_mat_file + ext
679679

Diff for: nipype/interfaces/cmtk/convert.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -194,17 +194,17 @@ 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 not string.find(data_name, "lengths") == -1:
197+
if string.find(data_name, 'lengths') != -1:
198198
cda.dtype = "FinalFiberLengthArray"
199-
if not string.find(data_name, "endpoints") == -1:
199+
if string.find(data_name, 'endpoints') != -1:
200200
cda.dtype = "FiberEndpoints"
201-
if not string.find(data_name, "labels") == -1:
201+
if string.find(data_name, 'labels') != -1:
202202
cda.dtype = "FinalFiberLabels"
203203
a.add_connectome_data(cda)
204204

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

@@ -213,7 +213,7 @@ def _run_interface(self, runtime):
213213
def _list_outputs(self):
214214
outputs = self._outputs().get()
215215
_, name, ext = split_filename(self.inputs.out_file)
216-
if not ext == ".cff":
216+
if ext != '.cff':
217217
ext = ".cff"
218218
outputs["connectome_file"] = op.abspath(name + ext)
219219
return outputs
@@ -281,7 +281,7 @@ def _run_interface(self, runtime):
281281
metadata.set_email("My Email")
282282

283283
_, name, ext = split_filename(self.inputs.out_file)
284-
if not ext == ".cff":
284+
if ext != '.cff':
285285
ext = ".cff"
286286
cf.save_to_cff(newcon, op.abspath(name + ext))
287287

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

Diff for: nipype/interfaces/cmtk/nx.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def average_networks(in_files, ntwk_res_file, group_id):
167167
data = ntwk.edge[edge[0]][edge[1]]
168168
if ntwk.edge[edge[0]][edge[1]]["count"] >= count_to_keep_edge:
169169
for key in list(data.keys()):
170-
if not key == "count":
170+
if key != "count":
171171
data[key] = data[key] / len(in_files)
172172
ntwk.edge[edge[0]][edge[1]] = data
173173
avg_ntwk.add_edge(edge[0], edge[1], **data)
@@ -184,7 +184,7 @@ def average_networks(in_files, ntwk_res_file, group_id):
184184
for edge in avg_edges:
185185
data = avg_ntwk.edge[edge[0]][edge[1]]
186186
for key in list(data.keys()):
187-
if not key == "count":
187+
if key != "count":
188188
edge_dict[key] = np.zeros(
189189
(avg_ntwk.number_of_nodes(), avg_ntwk.number_of_nodes())
190190
)
@@ -342,7 +342,7 @@ def add_node_data(node_array, ntwk):
342342
node_ntwk = nx.Graph()
343343
newdata = {}
344344
for idx, data in ntwk.nodes(data=True):
345-
if not int(idx) == 0:
345+
if int(idx) != 0:
346346
newdata["value"] = node_array[int(idx) - 1]
347347
data.update(newdata)
348348
node_ntwk.add_node(int(idx), **data)
@@ -354,7 +354,7 @@ def add_edge_data(edge_array, ntwk, above=0, below=0):
354354
data = {}
355355
for x, row in enumerate(edge_array):
356356
for y in range(np.max(np.shape(edge_array[x]))):
357-
if not edge_array[x, y] == 0:
357+
if edge_array[x, y] != 0:
358358
data["value"] = edge_array[x, y]
359359
if data["value"] <= below or data["value"] >= above:
360360
if edge_ntwk.has_edge(x + 1, y + 1):

Diff for: nipype/interfaces/dcmstack.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def _run_interface(self, runtime):
152152
meta_filter = dcmstack.make_key_regex_filter(exclude_regexes, include_regexes)
153153
stack = dcmstack.DicomStack(meta_filter=meta_filter)
154154
for src_path in src_paths:
155-
if not imghdr.what(src_path) == "gif":
155+
if imghdr.what(src_path) != "gif":
156156
src_dcm = pydicom.dcmread(src_path, force=self.inputs.force_read)
157157
stack.add_dcm(src_dcm)
158158
nii = stack.to_nifti(embed_meta=True)

Diff for: nipype/interfaces/io.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1053,9 +1053,9 @@ def s3tolocal(self, s3path, bkt):
10531053
local_directory = str(self.inputs.local_directory)
10541054
bucket_path = str(self.inputs.bucket_path)
10551055
template = str(self.inputs.template)
1056-
if not os.path.basename(local_directory) == "":
1056+
if os.path.basename(local_directory) != "":
10571057
local_directory += "/"
1058-
if not os.path.basename(bucket_path) == "":
1058+
if os.path.basename(bucket_path) != "":
10591059
bucket_path += "/"
10601060
if template[0] == "/":
10611061
template = template[1:]

Diff for: nipype/interfaces/mne/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def _list_outputs(self):
138138
else:
139139
raise TypeError
140140
outputs[k] = out_files
141-
if not k.rfind("surface") == -1:
141+
if k.rfind("surface") != -1:
142142
mesh_paths.append(out_files)
143143
outputs["mesh_files"] = mesh_paths
144144
return outputs

Diff for: nipype/interfaces/mrtrix/convert.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def track_gen(track_points):
116116
pts_str = fileobj.read(n_pts * bytesize)
117117
nan_str = fileobj.read(bytesize)
118118
if len(pts_str) < (n_pts * bytesize):
119-
if not n_streams == stream_count:
119+
if n_streams != stream_count:
120120
raise nb.trackvis.HeaderError(
121121
f"Expecting {stream_count} points, found only {n_streams}"
122122
)

0 commit comments

Comments
 (0)