Sourcery refactored master branch - #32
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.
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))
| y = np.empty((n_trials)) | ||
|
|
||
| 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.
Function signal_ndarray refactored with the following changes:
- Replace list(), dict() or set() with comprehension (
collection-builtin-to-comprehension)
| c = np.array(range(2, 12)) | ||
| sa, sb, sc = unison_shuffled_copies(a, b, c) | ||
| 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.
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.
Function aggregate_windows_to_epochs refactored with the following changes:
- Hoist repeated code outside conditional statement (
hoist-statement-from-if)
| info = mne.create_info(ch_names=ch_names, sfreq=sfreq, ch_types=ch_types) | ||
| raw = mne.io.RawArray(eeg_data, info) | ||
| return raw | ||
| return mne.io.RawArray(eeg_data, info) |
There was a problem hiding this comment.
Function load_demo refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| checked = _check_samples(data.T, channel_names, max_uv_abs=max_uv_abs) # type: ignore | ||
| 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.
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.
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.
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.
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.
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❌ Patch coverage is
Additional details and impacted files@@ 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 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Branch
masterrefactored 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
masterbranch, then run:Help us improve this pull request!