Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STY: Apply ruff/flake8-simplify rules (SIM) #913

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions niworkflows/interfaces/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,7 @@ def _run_interface(self, runtime):
except ValueError:
pass
params = parse_file_entities(in_file)
self._results = {
key: params.get(key, Undefined) for key in _BIDSInfoOutputSpec().get().keys()
}
self._results = {key: params.get(key, Undefined) for key in _BIDSInfoOutputSpec().get()}
return runtime


Expand Down
2 changes: 1 addition & 1 deletion niworkflows/interfaces/surf.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def _outputs(self):
trait_change_notify=False,
**{
entity: Undefined
for entity in self._pattern.groupindex.keys()
for entity in self._pattern.groupindex
if entity not in self._excluded
},
)
Expand Down
3 changes: 1 addition & 2 deletions niworkflows/reports/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,7 @@ def _process_orderings(orderings, layout):
]
# if all values are None for an entity, we do not want to keep that entity
keep_idx = [
False if (len(val_set) == 1 and None in val_set) or not val_set else True
for val_set in unique_values
not (len(val_set) == 1 and None in val_set or not val_set) for val_set in unique_values
]
# the "kept" entities
entities = list(compress(orderings, keep_idx))
Expand Down
10 changes: 2 additions & 8 deletions niworkflows/utils/spaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,10 +521,7 @@ def __contains__(self, item):
if not self.references:
return False
item = self.check_space(item)
for s in self.references:
if s == item:
return True
return False
return any(s == item for s in self.references)

def __str__(self):
"""
Expand Down Expand Up @@ -730,10 +727,7 @@ def __call__(self, parser, namespace, values, option_string=None):

def hasspec(value, specs):
"""Check whether any of the keys are in a dict."""
for s in specs:
if s in value:
return True
return False
return any(s in value for s in specs)


def format_reference(in_tuple):
Expand Down
2 changes: 1 addition & 1 deletion niworkflows/utils/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def _cifti_timeseries(dataset):
}
seg = {label: [] for label in list(labels.values()) + ['Other']}
for bm in matrix.get_index_map(1).brain_models:
label = 'Other' if bm.brain_structure not in labels else labels[bm.brain_structure]
label = labels.get(bm.brain_structure, 'Other')
seg[label] += list(range(bm.index_offset, bm.index_offset + bm.index_count))

return dataset.get_fdata(dtype='float32').T, seg
Expand Down
Loading