Change in type promotion. Fixes to annotation.py#506
Conversation
|
Thanks for working on this!
Here, the original So I think this would probably work, but I think (since we're looping over the bytes in Python anyway) it'd be better to do the conversion one element at a time as needed. That is to say, changing something like |
NPY_PROMOTION_STATE=weak_and_warn reports that several variables changed from int64 to uint8.
|
Thanks! Like this? I don't see any particular reason to use int64 on the while loop, so went for int. |
|
Thanks. Unless I missed something, though, it looks like there's still an issue in line 2239. |
resolve UserWarning: result dtype changed due to the removal of value-based promotion from NumPy. Changed from int64 to uint8.
|
In line 2241, I think we want In addition to the ones you fixed, there's one more warning in line 2327 ( I'm not sure why not all of the warnings were showing up before. |
Sorry, good catch.
Odd, I see this now too: I have cast to int64 |
65c4b1b to
e729062
Compare
Adding just |
Sorry, this (e729062) does not fix it. "aux_notelen" is causing the warning. "aux_notebytes" is not a problem and there is no reason to change it. |
|
There is also something strange happening involving pandas in rdann |
|
Looks like a straight up pandas bug: |
|
Thanks Benjamin. Interested in seeing what happens with the Pandas issue! |
This pull request adds a changelog for `v4.2.0`. The changelog is based on the following auto-generated summary of merge commits generated by GitHub: ``` ## What's Changed * bug-fix: Numpy ValueError when cheking empty list equality by @ajadczaksunriselabs in #459 * bug-fix: Pandas set indexing error by @ajadczaksunriselabs in #460 * fix for /issues/452 by @tecamenz in #465 * Use numpydoc to render documentation by @SnoopJ in #472 * build(deps): bump readthedocs-sphinx-search from 0.1.1 to 0.3.2 in /docs by @dependabot in #477 * Update style by @bemoody in #482 * Fix NaN handling in Record.adc, and other fixes by @bemoody in #481 * Set upper bound on Numpy version (numpy = ">=1.10.1,<2.0.0"). Ref #493. by @tompollard in #494 * Update actions to use actions/checkout@v3 and actions/setup-python@v4. by @tompollard in #495 * Fix: Indent code to ensure 'j' is within for-loop in GQRS algorithm by @tompollard in #499 * Add write_dir argument to csv_to_wfdb. Fixes #67. by @tompollard in #492 * Fix warnings by @cbrnr in #502 * README improvements by @bemoody in #503 * Change in type promotion. Fixes to annotation.py by @tompollard in #506 * Use uv by @cbrnr in #504 * Change in type promotion. Fixes to _signal.py by @tompollard in #507 * Test round-trip write/read of supported binary formats by @bemoody in #509 * Corrected typo and extended allowed types for MultiSegmentRecord by @agent3gatech in #514 * Allow expanded physical signal in `calc_adc_params` by @briangow in #512 * Add capability to write signal with unique `samps_per_frame` to `wfdb.io.wrsamp` by @briangow in #510 * Fix selection of channels when converting to EDF by @SamJelfs in #519 * Change in type promotion introduced in Numpy 2.0. Fixes to edf.py. by @tompollard in #527 * Bump dependencies for NumPy 2 compatibility by @cbrnr in #511 * Bump version to v4.2.0 and update notes on creating new releases by @tompollard in #497 ## New Contributors * @ajadczaksunriselabs made their first contribution in #459 * @tecamenz made their first contribution in #465 * @SnoopJ made their first contribution in #472 * @dependabot made their first contribution in #477 * @agent3gatech made their first contribution in #514 * @SamJelfs made their first contribution in #519 **Full Changelog**: v4.1.2...v4.2.0 ```
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.2andNPY_PROMOTION_STATE=weak_and_warnraises the following warnings for wfdb/io/annotation.py:The changes in this pull request address these issues by explicitly casting the type. I plan to follow up with several additional fixes to other modules.