-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
DOC: Migration guide should mention complex number API changes #25294
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
Comments
Every standard defines this to be ABI equivalent to the struct. So the offsets are trivially 0 and sizeof(floating_type)? I mean, there is also a macro version to get the imag/real, but I doubt it isn't easier to just hardcode something |
Makes sense. So sanity check: |
Should we maybe have a paragraph on this in the migration guide that we can point people to? ping @lysnikolaou too since they drove most of the effort on this. |
Oh yes I meant to mention that. I didn't notice the complex change in the C-API issue (#25292 #API) nor in the version 2 release notes. |
There's a section on all of this on https://numpy.org/devdocs/reference/c-api/coremath.html#support-for-complex-numbers. We should probably link to it from the release notes and/or the migration guide though. |
Changed the title to reflect that the new docs linked to above just need to be a bit more discoverable for people porting code for numpy 2.0. |
One thing the section might grow, is that it is perfectly fine to vendor the struct definition or the std one especially on C++ (who don't use |
+1 for linking to this from the 2.0 migration guide, we just bumped into this in scipy/scipy#19587 and that was the first place I checked. |
Describe the issue:
I'm helping the h5py project migrate to Cython 3 and while doing so also tested with numpy 2.0 (
main
). I discovered some compilation errors which you can read in detail here:h5py/h5py#2348
Basically h5py uses a macro from the HDF5 C++ library to get the offset into a struct for the "real" and "imag" members, but now complex types in numpy's C API are not structs (#24085). So I'm wondering what the best long term solution is to work around this. The h5py code doing this looks like this:
Reproduce the code example:
Error message:
Python and NumPy Versions:
Python 3.11
Numpy 2.0 (main)
Runtime Environment:
No response
Context for the issue:
Currently affecting h5py compatibility with numpy 2.0.
The text was updated successfully, but these errors were encountered: