[ENH] ASR: build clean_windows sample mask without quadratic concat - #105
Merged
sappelhoff merged 2 commits intoJul 10, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #105 +/- ##
==========================================
+ Coverage 83.12% 83.15% +0.02%
==========================================
Files 25 25
Lines 2827 2820 -7
==========================================
- Hits 2350 2345 -5
+ Misses 477 475 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The set of samples to drop was accumulated by repeatedly concatenating per-window index ranges with `np.r_[...]` inside a loop, which reallocates a growing array on every removed window (O(k^2) in the number of removed windows) and materialises a large index array before `np.unique` / `np.delete`. Mark the samples to remove directly in a boolean mask of length n_samples instead. This is O(n_samples), allocates once, and drops the `np.unique`/`np.delete` round-trip. `X` is returned untouched (no copy) when nothing is removed, matching the previous behaviour. Output (`clean`, `sample_mask`) is bit-identical on the test data.
nbara
force-pushed
the
perf/asr-cleanwindows-boolmask
branch
from
July 7, 2026 13:03
8616412 to
e82b383
Compare
nbara
approved these changes
Jul 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The set of samples to drop in
clean_windowswas accumulated by repeatedlyconcatenating per-window index ranges with
np.r_[...]inside a loop. Thisreallocates a growing array on every removed window (O(k²) in the number of
removed windows) and materialises a large index array before
np.unique/np.delete.Mark the samples to remove directly in a boolean mask of length
n_samplesinstead. This is O(n_samples), allocates once, and drops the
np.unique/np.deleteround-trip.Xis returned untouched (no copy) whennothing is removed, matching the previous behaviour.
Correctness
cleanandsample_maskare bit-identical on the test data.