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. Fixes to _signal.py (#507)
As discussed in #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/_signal.py: ``` tests/test_record.py::TestRecord::test_1a /Users/tompollard/projects/wfdb-python/wfdb/io/_signal.py:2374: UserWarning: result dtype changed due to the removal of value-based promotion from NumPy. Changed from int32 to int16. d_signal[d_signal < 0] = d_signal[d_signal < 0] + 65536 ``` The changes in this pull request address these issues by explicitly casting the type. I also make a couple of minor modifications for efficiency (switching to inplace addition). I plan to follow up with several additional fixes to other modules.
- Loading branch information