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 — f2py: `complex_long_double` maps to `NPY_CDOUBLE` in `c2capi_map`, inconsistent with `c2pycode_map` which assigns a distinct type code · Issue #31012 · numpy/numpy

f2py: complex_long_double maps to NPY_CDOUBLE in c2capi_map, inconsistent with c2pycode_map which assigns a distinct type code #31012

New issue
Copy link
New issue
Copy link
Closed
Closed
f2py: complex_long_double maps to NPY_CDOUBLE in c2capi_map, inconsistent with c2pycode_map which assigns a distinct type code#31012
Copy link

Description

@tejas-ae
tejas-ae
opened on Mar 13, 2026
Issue body actions

In numpy/f2py/capi_maps.py, the three type-mapping dicts handle complex_long_double inconsistently:

# c2capi_map (lines ~71-75) — used to select the NumPy C API dtype
'complex_double':      'NPY_CDOUBLE',
'complex_long_double': 'NPY_CDOUBLE',   # same as complex_double — precision silently lost?

# c2pycode_map (lines ~91-93) — used to build Python format strings
'complex_double':      'D',
'complex_long_double': 'G',             # distinct code

# c2buildvalue_map
'complex_double':      'N',
'complex_long_double': 'N',             # same

c2pycode_map assigns 'G' to complex_long_double, implying the type is recognised as distinct. But c2capi_map maps it to the same NPY_CDOUBLE as complex_double.

Compare with real types: long_double correctly maps to NPY_LONGDOUBLE, preserving extended precision. There is no corresponding NPY_CLONGDOUBLE mapping for the complex counterpart.

Questions:

  1. Is the downcast of complex_long_double → NPY_CDOUBLE intentional (e.g. no platform-portable complex-long-double C API type exists)?
  2. If intentional, should a warning be emitted when f2py wraps a Fortran COMPLEX*32 or similar to alert users to the precision loss?
  3. Should the three maps be audited for consistency, or is the divergence between c2capi_map and c2pycode_map load-bearing?

File: numpy/f2py/capi_maps.py

Activity

  1. Anarion-zuo commented on Mar 22, 2026

    @Anarion-zuo
    Anarion-zuo
    on Mar 22, 2026
    Contributor
    More actions

    We had a solution here. #31047

    Reacted by Tejas Attarde
  2. tejas-ae commented on Mar 22, 2026

    @tejas-ae
    tejas-ae
    on Mar 22, 2026
    Author
    More actions

    Hey, Thanks for the clarification!

  3. tejas-ae
    closed this as completedon Mar 22, 2026
  4. mohammedsalman06112-blip commented on Mar 23, 2026

    @mohammedsalman06112-blip
    mohammedsalman06112-blip
    on Mar 23, 2026 via email · Hidden as spam
    show commentMore actions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      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.