-
Notifications
You must be signed in to change notification settings - Fork 4
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
Sourcery refactored master branch #32
base: master
Are you sure you want to change the base?
Conversation
bads = [] | ||
for i, row in df.iterrows(): | ||
# print(_row_stats(row)) | ||
if not _check_row_signal_quality(row, max_uv_abs, max_std): | ||
bads.append(i) | ||
bads = [ | ||
i | ||
for i, row in df.iterrows() | ||
if not _check_row_signal_quality(row, max_uv_abs, max_std) | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function _clean_signal_quality
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
)
This removes the following comments ( why? ):
# print(_row_stats(row))
catmap = dict(((cls, i) for i, cls in enumerate(df["class"].cat.categories))) | ||
catmap = {cls: i for i, cls in enumerate(df["class"].cat.categories)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function signal_ndarray
refactored with the following changes:
- Replace list(), dict() or set() with comprehension (
collection-builtin-to-comprehension
)
assert all([v1 == v2 - 1 == v3 - 2 for v1, v2, v3 in zip(sa, sb, sc)]) | ||
assert all(v1 == v2 - 1 == v3 - 2 for v1, v2, v3 in zip(sa, sb, sc)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function test_unison_shuffled_copies
refactored with the following changes:
- Replace unneeded comprehension with generator (
comprehension-to-generator
)
votes.append(vote > 0.5) | ||
else: | ||
# Use the mean probability | ||
vote = np.mean(predicted_proba[test][i_start : i_stop + 1, 1]) | ||
votes.append(vote > 0.5) | ||
|
||
votes.append(vote > 0.5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function aggregate_windows_to_epochs
refactored with the following changes:
- Hoist repeated code outside conditional statement (
hoist-statement-from-if
)
raw = mne.io.RawArray(eeg_data, info) | ||
return raw | ||
return mne.io.RawArray(eeg_data, info) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function load_demo
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
bads = [ch for ch, ok in checked.items() if not ok] | ||
return bads | ||
return [ch for ch, ok in checked.items() if not ok] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function BrainflowDevice.check
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
# Subtract five seconds of settling time from beginning | ||
# total_data = total_data[5 * self.sfreq :] | ||
df = pd.DataFrame( | ||
return pd.DataFrame( | ||
total_data, | ||
columns=["timestamps"] + ch_names + (["stim"] if self.markers else []), | ||
) | ||
return df |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function BrainflowDevice.get_data
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
This removes the following comments ( why? ):
# total_data = total_data[5 * self.sfreq :]
# Subtract five seconds of settling time from beginning
if self.stream_process: | ||
return self.stream_process.exitcode is None | ||
return False | ||
return self.stream_process.exitcode is None if self.stream_process else False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function MuseDevice.started
refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else
) - Replace if statement with if expression (
assign-if-exp
)
for i in range(5): | ||
for _ in range(5): | ||
for inlet in inlets: | ||
inlet.pull(timeout=0.5) # type: ignore | ||
inlets = [inlet for inlet in inlets if inlet.buffer.any()] # type: ignore | ||
if inlets: | ||
break | ||
else: | ||
logger.info("No inlets with data, trying again in a second...") | ||
sleep(1) | ||
logger.info("No inlets with data, trying again in a second...") | ||
sleep(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function MuseDevice._read_buffer
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
) - Remove unnecessary else after guard condition (
remove-unnecessary-else
)
bads = [ch for ch, ok in checked.items() if not ok] | ||
return bads | ||
return [ch for ch, ok in checked.items() if not ok] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function MuseDevice.check
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.06%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Help us improve this quality report! |
Codecov Report
@@ Coverage Diff @@
## master #32 +/- ##
==========================================
- Coverage 65.93% 65.53% -0.40%
==========================================
Files 22 22
Lines 1224 1213 -11
==========================================
- Hits 807 795 -12
- Misses 417 418 +1
Continue to review full report at Codecov.
|
Branch
master
refactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
master
branch, then run:Help us improve this pull request!