Repository navigation
Commit a4487f2
authored
[FIX] ASR: init clean_windows rejection masks before one-sided zthresholds (#113)
In `clean_windows`, `mask1` and `mask2` were only assigned inside their
respective `if np.max(zthresholds) > 0` / `if np.min(zthresholds) < 0`
branches, but combined unconditionally via `np.logical_or.reduce((mask1,
mask2, mask3))`. Since `zthresholds` is a documented, user-facing
parameter, passing a one-sided value (e.g. `[1, 2]` or `[-5, -1]`) skips
one branch and raises `UnboundLocalError`. The default `[-3.5, 5]`
straddles 0 so both branches run, keeping the bug latent.
Initialize both masks to all-`False` before the conditionals, so a
criterion that isn't evaluated simply rejects no windows.
### Testing
Added a regression test exercising `clean_windows` with both one-sided
directions of `zthresholds`. Full `tests/test_asr.py` passes; `ruff`
clean.1 parent 6b107c9 commit a4487f2
2 files changed
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
361 | 361 | | |
362 | 362 | | |
363 | 363 | | |
| 364 | + | |
| 365 | + | |
364 | 366 | | |
365 | 367 | | |
366 | 368 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
192 | 215 | | |
193 | 216 | | |
194 | 217 | | |
| |||
0 commit comments