Skip to content

Numpy 2+ support #937

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

Merged
merged 4 commits into from
May 23, 2025
Merged

Numpy 2+ support #937

merged 4 commits into from
May 23, 2025

Conversation

BBC-Esq
Copy link
Contributor

@BBC-Esq BBC-Esq commented May 22, 2025

This PR is relatively simple. As it turns out, the codebase was essentially compatible with Numpy 2+ already. For a fuller analysis, see my outline here:

#925

There was one "recommended" (but not mandatory) change, however, that will improve improves numerical stability that I implemented. Under the new "type-promotion" rules (NEP 50) says that when a Python float (default float64) is combined with a float32 array, the result’s dtype follows the higher-precision scalar—i.e., the array is up-cast to float64.
By writing

thr = np.float32(1e-5)
mask = np.abs(wav) > thr          # both operands now float32

Basically, we keep the comparison in float32, preserving:

  • Memory footprint – no temporary 64-bit copy is created.
  • Speed – SIMD paths for float32 aren’t lost.
  • Numerical parity – results match the older 1.26 behavior.

Again, the tweak isn't mandatory, but it keeps the code's code’s performance and dtype expectations identical after upgrading to NumPy 2 +.

Please change the requirements to numpy any version LESS THAN 3...and then when 3 is released we can revisit the issue of compatibility. Thanks.

@github-actions github-actions bot changed the base branch from main to dev May 22, 2025 10:53
@BBC-Esq
Copy link
Contributor Author

BBC-Esq commented May 22, 2025

I'm not sure why this workflow would have failed but let me know your thoughts.

@fumiama
Copy link
Member

fumiama commented May 23, 2025

I will check it. It seems not your fault.

@fumiama fumiama added the enhancement New feature or request label May 23, 2025
fumiama
fumiama previously approved these changes May 23, 2025
@fumiama fumiama merged commit 1092c1f into 2noise:dev May 23, 2025
5 checks passed
@BBC-Esq
Copy link
Contributor Author

BBC-Esq commented May 23, 2025

Thanks, when will a new release be done so that "pip check" doesn't show a conflict?

@fumiama
Copy link
Member

fumiama commented May 23, 2025

You can upgrade and check it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants