Skip to content

Commit 21d5af6

Browse files
authored
Merge pull request #913 from DimitriPapadopoulos/SIM
STY: Apply ruff/flake8-simplify rules (SIM)
2 parents a3fbbf3 + cb5e270 commit 21d5af6

File tree

5 files changed

+6
-15
lines changed

5 files changed

+6
-15
lines changed

niworkflows/interfaces/bids.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,7 @@ def _run_interface(self, runtime):
216216
except ValueError:
217217
pass
218218
params = parse_file_entities(in_file)
219-
self._results = {
220-
key: params.get(key, Undefined) for key in _BIDSInfoOutputSpec().get().keys()
221-
}
219+
self._results = {key: params.get(key, Undefined) for key in _BIDSInfoOutputSpec().get()}
222220
return runtime
223221

224222

niworkflows/interfaces/surf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def _outputs(self):
182182
trait_change_notify=False,
183183
**{
184184
entity: Undefined
185-
for entity in self._pattern.groupindex.keys()
185+
for entity in self._pattern.groupindex
186186
if entity not in self._excluded
187187
},
188188
)

niworkflows/reports/core.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,7 @@ def _process_orderings(orderings, layout):
463463
]
464464
# if all values are None for an entity, we do not want to keep that entity
465465
keep_idx = [
466-
False if (len(val_set) == 1 and None in val_set) or not val_set else True
467-
for val_set in unique_values
466+
not (len(val_set) == 1 and None in val_set or not val_set) for val_set in unique_values
468467
]
469468
# the "kept" entities
470469
entities = list(compress(orderings, keep_idx))

niworkflows/utils/spaces.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -521,10 +521,7 @@ def __contains__(self, item):
521521
if not self.references:
522522
return False
523523
item = self.check_space(item)
524-
for s in self.references:
525-
if s == item:
526-
return True
527-
return False
524+
return any(s == item for s in self.references)
528525

529526
def __str__(self):
530527
"""
@@ -730,10 +727,7 @@ def __call__(self, parser, namespace, values, option_string=None):
730727

731728
def hasspec(value, specs):
732729
"""Check whether any of the keys are in a dict."""
733-
for s in specs:
734-
if s in value:
735-
return True
736-
return False
730+
return any(s in value for s in specs)
737731

738732

739733
def format_reference(in_tuple):

niworkflows/utils/timeseries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def _cifti_timeseries(dataset):
4242
}
4343
seg = {label: [] for label in list(labels.values()) + ['Other']}
4444
for bm in matrix.get_index_map(1).brain_models:
45-
label = 'Other' if bm.brain_structure not in labels else labels[bm.brain_structure]
45+
label = labels.get(bm.brain_structure, 'Other')
4646
seg[label] += list(range(bm.index_offset, bm.index_offset + bm.index_count))
4747

4848
return dataset.get_fdata(dtype='float32').T, seg

0 commit comments

Comments
 (0)