Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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-L355
- Loading branch information