Repository navigation
Commit 3547521
authored
Sum whole signals at once in _checksums (#676)
A small follow-up to #653. `_checksums` sums each column in a Python
loop, which has two side effects for `calc_checksum`:
| | `axis=0` (this PR) | per column |
|---|---|---|
| 10M x 12, int16 | 74 ms | 40 ms |
| 10M x 2, int32 | 40 ms | 6 ms |
| 1M x 64, int16 | 25 ms | 138 ms |
| 1-D `d_signal` | `TypeError` | `[0, 1, 2, ...]` |
The loop is faster for records with few channels, but several times
slower for recordings with many channels. The absolute cost is small
either way. The more important difference is that a 1-D array returns
one value per sample instead of raising an error.
`_checksums` goes back to a single reduction along axis 0, which is what
`calc_checksum` and `wfdb_to_mat` used before #653. For integer samples
the result is the same either way.
`read_edf` is the only caller with float samples, where the order of the
additions can change the truncated result (ten values of 0.1 sum to 1.0
by column, and to 0.9999999999999999 along axis 0). It keeps summing
each channel separately, so its checksums don't change.
Testing:
- `test_checksums_rejects_1d` is restored.
- New `test_float_checksum` reads a small two-channel EDF file and
checks the checksums. It fails if `read_edf` uses `_checksums`.
- `uv run pytest -m "not network" -W error` passes (566), as do `ruff
format --check` and `ruff check`.
No changelog entry, since #653 is not released and behaviour is the same
as in the last release.
<sub>@tompollard 🟥 red 🐳 whale · quince</sub>4 files changed
Lines changed: 51 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | | - | |
| 147 | + | |
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
431 | 431 | | |
432 | 432 | | |
433 | 433 | | |
434 | | - | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
435 | 439 | | |
436 | 440 | | |
437 | 441 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
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 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
145 | 185 | | |
146 | 186 | | |
147 | 187 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1873 | 1873 | | |
1874 | 1874 | | |
1875 | 1875 | | |
1876 | | - | |
1877 | | - | |
1878 | | - | |
1879 | | - | |
1880 | | - | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
1881 | 1880 | | |
1882 | 1881 | | |
1883 | 1882 | | |
| |||
0 commit comments