Repository navigation
Commit 1ae2321
authored
[FIX] ASR: round half away from zero for window/bad-chan counts (#116)
numpy's `np.round` (banker's rounding, round-half-to-even) and Python's
`int()` truncation diverge from MATLAB's round-half-away-from-zero at
exact-half inputs, giving ±1 counts for the bad-channel count and window
length `N` in `clean_windows` and `asr_calibrate`. Add a
`_round_half_away` helper and apply it at those sites.
Reachability is narrow (ties need specific channel counts or odd-integer
`sfreq` with `win_len=0.5`; common rates never trigger), so this mainly
hardens the edge cases.
### Testing
Added a helper unit test covering ties (`2.5→3`, `128.5→129`,
`-2.5→-3`), divergence from `np.round`, array input, and `int()`
exactness. Full `tests/test_asr.py` passes; `ruff` clean.1 parent cbc8943 commit 1ae2321
2 files changed
Lines changed: 41 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
291 | 300 | | |
292 | 301 | | |
293 | 302 | | |
| |||
354 | 363 | | |
355 | 364 | | |
356 | 365 | | |
357 | | - | |
| 366 | + | |
358 | 367 | | |
359 | 368 | | |
360 | 369 | | |
361 | | - | |
| 370 | + | |
362 | 371 | | |
363 | 372 | | |
364 | 373 | | |
| |||
543 | 552 | | |
544 | 553 | | |
545 | 554 | | |
546 | | - | |
| 555 | + | |
547 | 556 | | |
548 | 557 | | |
549 | 558 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
145 | 173 | | |
146 | 174 | | |
147 | 175 | | |
| |||
0 commit comments