BUG: f2py map complex_long_double to NPY_CLONGDOUBLE#31047
Merged
HaoZeke merged 2 commits intoApr 1, 2026
Conversation
Member
|
@jorenham do you understand why the type coverage tests failed on this PR? |
ngoldbaum
reviewed
Mar 23, 2026
Member
Because the Which begs the question: why didn't you just add the tests to |
Contributor
Author
|
Sorry. It would seem I accidentally used some of our internal directory structure. Will fix this ASAP. |
Signed-off-by: aaronzuo <anarionzuo@outlook.com>
Contributor
Author
|
@jorenham Just removed the unwanted folder. |
ngoldbaum
approved these changes
Mar 31, 2026
ngoldbaum
left a comment
Member
There was a problem hiding this comment.
Looks like a straightforward fix to me.
Member
Member
|
Thanks @ngoldbaum @Anarion-zuo |
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
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.
PR summary
Resolved issue #31012.
This PR fixes an inconsistency in f2py’s C-type → NumPy C-API dtype mapping for extended-precision complex values.
c2capi_map["complex_long_double"]was mapped toNPY_CDOUBLE, which can silently downcastcomplex_long_doubleto double precision when selecting the NumPy dtype typenum. At the same time,c2pycode_mapalready treatedcomplex_long_doubleas distinct ('G'vs'D'), implying support for a separate type.complex_long_doubletoNPY_CLONGDOUBLEinc2capi_map, aligning dtype selection with NumPy’sclongdoubledtype and f2py’s existing internal support fornpy_clongdouble.numpy/f2py/tests_pure/) that asserts:complex_long_doublemaps toNPY_CLONGDOUBLEcomplex_long_doubleis distinct fromcomplex_doublein bothc2capi_mapandc2pycode_mapRun locally:
First time committer introduction
I’m a first-time NumPy contributor. I use NumPy for scientific computing and data analysis workflows, and I rely on f2py to integrate legacy Fortran code into Python. I noticed the complex_long_double mapping inconsistency when working with extended-precision complex data, and wanted to fix it to avoid silent precision loss for users.
AI Disclosure
No AI tools are used.