GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — BUG: f2py map complex_long_double to NPY_CLONGDOUBLE by Anarion-zuo · Pull Request #31047 · numpy/numpy

Conversation

@Anarion-zuo

@Anarion-zuo Anarion-zuo commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

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.

  • Problem: In capi_maps.py, c2capi_map["complex_long_double"] was mapped to NPY_CDOUBLE, which can silently downcast complex_long_double to double precision when selecting the NumPy dtype typenum. At the same time, c2pycode_map already treated complex_long_double as distinct ('G' vs 'D'), implying support for a separate type.
  • Fix: Map complex_long_double to NPY_CLONGDOUBLE in c2capi_map, aligning dtype selection with NumPy’s clongdouble dtype and f2py’s existing internal support for npy_clongdouble.
  • Tests: Add a pure-Python regression test (in numpy/f2py/tests_pure/) that asserts:
    • complex_long_double maps to NPY_CLONGDOUBLE
    • complex_long_double is distinct from complex_double in both c2capi_map and c2pycode_map

Run locally:

python -m pytest numpy/f2py/tests_pure/test_capi_maps.py -q

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Anarion-zuo
fix: f2py map complex_long_double to NPY_CLONGDOUBLE
964ea6f
@Anarion-zuo Anarion-zuo mentioned this pull request Mar 22, 2026
f2py: complex_long_double maps to NPY_CDOUBLE in c2capi_map, inconsistent with c2pycode_map which assigns a distinct type code #31012
Closed
@charris charris changed the title fix: f2py map complex_long_double to NPY_CLONGDOUBLE BUG: f2py map complex_long_double to NPY_CLONGDOUBLE Mar 22, 2026
@charris charris added 00 - Bug 09 - Backport-Candidate PRs tagged should be backported component: numpy.f2py labels Mar 22, 2026
themavik
themavik reviewed Mar 23, 2026
View reviewed changes

@themavik themavik left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

block test

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ngoldbaum

ngoldbaum commented Mar 23, 2026

Copy link
Copy Markdown
Member

@jorenham do you understand why the type coverage tests failed on this PR?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ngoldbaum
ngoldbaum reviewed Mar 23, 2026
View reviewed changes
Comment thread numpy/f2py/tests/test_capi_maps.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@jorenham

jorenham commented Mar 23, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

@jorenham do you understand why the type coverage tests failed on this PR?

Because the numpy/f2py/tests_pure/test_capi_maps.py (or anything in numpy/f2py/tests_pure for that matter) isn't excluded.

Which begs the question: why didn't you just add the tests to numpy/f2py/tests and instead created a new numpy/f2py/tests_pure directory, @Anarion-zuo ?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Anarion-zuo

Anarion-zuo commented Mar 25, 2026

Copy link
Copy Markdown
Contributor Author

Sorry. It would seem I accidentally used some of our internal directory structure. Will fix this ASAP.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Anarion-zuo
fix dir structure
86378b1
Signed-off-by: aaronzuo <[email protected]>
@Anarion-zuo

Anarion-zuo commented Mar 30, 2026

Copy link
Copy Markdown
Contributor Author

@jorenham Just removed the unwanted folder.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ngoldbaum
ngoldbaum approved these changes Mar 31, 2026
View reviewed changes

@ngoldbaum ngoldbaum left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a straightforward fix to me.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ngoldbaum ngoldbaum added this to the 2.4.5 release milestone Mar 31, 2026
@ngoldbaum

ngoldbaum commented Mar 31, 2026

Copy link
Copy Markdown
Member

@charris @HaoZeke would one of you like to hit the merge button?

HaoZeke reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@HaoZeke
HaoZeke merged commit 0d92b75 into numpy:main Apr 1, 2026
82 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@HaoZeke

HaoZeke commented Apr 1, 2026

Copy link
Copy Markdown
Member

Thanks @ngoldbaum @Anarion-zuo

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@charris charris mentioned this pull request Apr 10, 2026
BUG: f2py map complex_long_double to NPY_CLONGDOUBLE #31199
Merged
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ngoldbaum ngoldbaum ngoldbaum approved these changes
+1 more reviewer
@themavik themavik themavik left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

00 - Bug component: numpy.f2py

Projects

None yet

Milestone

2.4.5 release

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@Anarion-zuo @ngoldbaum @jorenham @HaoZeke @themavik @charris
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.