Commit e5c6fe5
authored
Change in type promotion introduced in Numpy 2.0. Fixes to edf.py. (#527)
As discussed in #493, numpy
2.0 introduced changes to type promotion. The change is outlined at:
https://numpy.org/devdocs/numpy_2_0_migration_guide.html#changes-to-numpy-data-type-promotion
Running the tests in `weak_and_warn` raises the following warnings:
```
tests/io/test_convert.py::TestEdfToWfdb::test_edf_uniform
/Users/tompollard/projects/wfdb-python/wfdb/io/convert/edf.py:409: UserWarning: result dtype changed due to the removal of value-based promotion from NumPy. Changed from int16 to int64.
temp_all_sigs[i].flatten() - baseline[i]
tests/io/test_convert.py::TestEdfToWfdb::test_edf_non_uniform
/Users/tompollard/projects/wfdb-python/wfdb/io/convert/edf.py:420: UserWarning: result dtype changed due to the removal of value-based promotion from NumPy. Changed from int16 to int64.
(temp_sig_data[start_ind:stop_ind] - baseline[i])
tests/io/test_convert.py::TestEdfToWfdb::test_edf_non_uniform
/Users/tompollard/projects/wfdb-python/wfdb/io/convert/edf.py:414: UserWarning: result dtype changed due to the removal of value-based promotion from NumPy. Changed from int16 to int64.
sig_data[:, i] = (temp_sig_data - baseline[i]) / adc_gain_all[i]
```
This pull request addresses the issue by setting `temp_all_sigs` and
`temp_sig_data` to `np.int64`.
For reference, `temp_all_sigs` and `temp_sig_data` are initially set as
`np.int64`:
https://github.com/MIT-LCP/wfdb-python/blob/c6d4fd9f05007ebc5f79dd07332f34410d7b8493/wfdb/io/convert/edf.py#L402-L404
`baseline` is set to `int64` here:
https://github.com/MIT-LCP/wfdb-python/blob/c6d4fd9f05007ebc5f79dd07332f34410d7b8493/wfdb/io/convert/edf.py#L353-L3551 file changed
+8
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
402 | 402 | | |
403 | 403 | | |
404 | 404 | | |
| 405 | + | |
405 | 406 | | |
406 | 407 | | |
407 | 408 | | |
408 | 409 | | |
409 | | - | |
| 410 | + | |
410 | 411 | | |
411 | 412 | | |
412 | 413 | | |
| 414 | + | |
413 | 415 | | |
414 | | - | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
415 | 419 | | |
416 | 420 | | |
417 | 421 | | |
418 | 422 | | |
419 | 423 | | |
420 | | - | |
421 | | - | |
| 424 | + | |
| 425 | + | |
422 | 426 | | |
423 | 427 | | |
424 | 428 | | |
| |||
0 commit comments