forked from pymc-devs/pytensor
-
Notifications
You must be signed in to change notification settings - Fork 0
Numpy2.0 complex types update #1
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
Open
brendan-m-murphy
wants to merge
24
commits into
main
Choose a base branch
from
numpy2.0-complex-types-update
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Also removes special case for old unsupported numpy 1.16
Numpy 2.0 uses C99 complex variables, which come in three varieties: complex floats, complex doubles, and complex long doubles. Numpy defines corresponding types: npy_cfloat, npy_cdouble, npy_clongdouble. We need to translate between these sizes and bit-width sizes, like npy_complex64 and npy_complex128. The alises added do so, as least in the cases where doubles have 32 or 64 bits
Updated pytensor_complex struct to use get/set real/imag aliases defined above. Note: redefining the complex arithmetic here means that we aren't treating NaNs and infinities as carefully as the C99 standard suggets (see Appendix G of the standard). The code has been like this since it was added to Theano, so we're keeping the existing behavior.
We need the bit width of the complex types so that we can choose the right get/set operators
Many more tests pass after fixing this.
Github merge added back some changes from the commit that removed custom complex types, which caused some tests to start failing again.
The macros select based on the underlying numpy type, so we don't need to find this explicitly, like the previous solution was doing.
These need to be copied into the source code since they're not available in Numpy 1.x. They define macros with the Numpy 1.x behavior for getting real and imaginary parts. In Numpy 2.0 these macros are already defined with the new definitions, so this addition to our code will be ignored in Numpy 2.0
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Related Issue
Checklist
Type of change