Skip to content

[ENH] ASR: build clean_windows sample mask without quadratic concat - #105

Merged
sappelhoff merged 2 commits into
nbara:masterfrom
sappelhoff:perf/asr-cleanwindows-boolmask
Jul 10, 2026
Merged

sappelhoff merged 2 commits into
nbara:masterfrom
sappelhoff:perf/asr-cleanwindows-boolmask

Conversation

@sappelhoff

Copy link
Copy Markdown
Collaborator

Summary

The set of samples to drop in clean_windows was accumulated by repeatedly
concatenating per-window index ranges with np.r_[...] inside a loop. This
reallocates 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_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.

Correctness

clean and sample_mask are bit-identical on the test data.

@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.15%. Comparing base (3e66fb1) to head (7b88a08).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nbara nbara changed the title perf(asr): build clean_windows sample mask without quadratic concat [ENH] ASR: build clean_windows sample mask without quadratic concat Jul 7, 2026
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
nbara force-pushed the perf/asr-cleanwindows-boolmask branch from 8616412 to e82b383 Compare July 7, 2026 13:03
@sappelhoff
sappelhoff merged commit 3c1e2e9 into nbara:master Jul 10, 2026
7 checks passed
@sappelhoff
sappelhoff deleted the perf/asr-cleanwindows-boolmask branch July 10, 2026 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants