BUG,MAINT: f2py
doesn't map iso_c_binding
values by default
#24553
Labels
f2py
doesn't map iso_c_binding
values by default
#24553
Uh oh!
There was an error while loading. Please reload this page.
Reproducer
Consider:
Which compiles fine but doesn't do what one might expect:
python -m numpy.f2py -c isoc_oddity.f90 -m buggy python -c 'import buggy;res=buggy.coddity.c_add(1, 2); print(f"res: {res}, exp: 3, eq: {res==3}")' a is 2.0000004731118679 b is 5.3049894774131808E-315 res: 1.0, exp: 3, eq: False
Clearly,
c_double
is not being interpreted correctly. This has an easy user-land fix though, adding an.f2py_f2cmap
file to the directory (or passing a named file in via the command line) with the following:Will work correctly:
python -m numpy.f2py -c isoc_oddity.f90 -m buggy --f2cmap isoc_f2cmap python -c 'import buggy;res=buggy.coddity.c_add(1, 2); print(f"res: {res}, exp: 3, eq: {res==3}")' a is 1.0000000000000000 b is 2.0000000000000000 res: 3.0, exp: 3, eq: True
Suggestion
This is definitely unexpected behavior,
iso_c_binding
values should be mapped correctly by default, or atleast loaded in when theiso_c_binding
module is used.The text was updated successfully, but these errors were encountered: