Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

numpy 2.0: workaround regression in rescaleData #2974

Merged
merged 1 commit into from Apr 17, 2024

Conversation

pijyoi
Copy link
Contributor

@pijyoi pijyoi commented Mar 31, 2024

Testing against NumPy 2.0rc1, a performance regression was noticed in functions.rescaleData.

The cause was traced to:
https://numpy.org/devdocs/numpy_2_0_migration_guide.html#changes-to-numpy-data-type-promotion

It does seem rather counter-intuitive that the new behavior should affect in-place operations:
e.g.

data -= offset
data *= scalar

i.e. the resultant dtype can't change, so the performance regression might imply that a temporary higher precision ndarray was created? This would defeat the purpose of doing in-place operations.

The fix in this PR is only applied to the numpy codepath, and not to the cupy and numba codepaths.
The numba codepath (functions_numba.rescaleData) already marks the offset and scale arguments as type f8.

@j9ac9k j9ac9k merged commit 45bf45c into pyqtgraph:master Apr 17, 2024
29 checks passed
@j9ac9k
Copy link
Member

j9ac9k commented Apr 17, 2024

Thanks for keeping the library up to date w/ issues with upcoming releases of our dependencies!

@pijyoi pijyoi deleted the npy2-float-promotion branch April 17, 2024 02:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants