wfdb-python
wfdb-python copied to clipboard
Change in type promotion. Fixes to edf.py
As discussed in https://github.com/MIT-LCP/wfdb-python/issues/493, numpy v2.0 introduced changes to type promotion rules: https://numpy.org/devdocs/numpy_2_0_migration_guide.html#changes-to-numpy-data-type-promotion
Running pytest with numpy==2.0.2 and NPY_PROMOTION_STATE=weak_and_warn raises the following warning for wfdb/io/convert/edf.py:
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]
The changes in this pull request address these issues by explicitly casting the type.