GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — ENH: Add templates for f2py c functions and handle more C types by Pranavchiku · Pull Request #25260 · numpy/numpy Conversation
HaoZeke
reviewed
Uh oh!
There was an error while loading. Please reload this page.
Pranavchiku
commented
Uh oh!
There was an error while loading. Please reload this page.
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Pranavchiku
force-pushed
the
gh25229
branch
2 times, most recently
from
9b71de9 to
0170e08
Compare
|
There was an error while loading. Please reload this page.
|
@Pranavchiku, the problem is essentially in the way the ❯ diff meson_works/codditymodule.c meson_broken/codditymodule.c 2c2 < * This file is auto-generated with f2py (version:2.0.0.dev0+git20231224.a43c068). --- > * This file is auto-generated with f2py (version:2.0.0.dev0+git20231222.94d21b0). 5c5 < * Generation date: Sun Dec 24 18:19:50 2023 --- > * Generation date: Sun Dec 24 18:24:33 2023 140a141,152 > static int > float_from_pyobj(float* v, PyObject *obj, const char *errmess) > { > double d=0.0; > if (double_from_pyobj(&d,obj,errmess)) { > *v = (float)d; > return 1; > } > return 0; > } > > 170c182 < void (*f2py_func)(double*,double*,double*)) { --- > void (*f2py_func)(float*,float*,float*)) { 175c187 < double a = 0; --- > float a = 0; 177c189 < double b = 0; --- > float b = 0; 179c191 < double c = 0; --- > float c = 0; 192c204 < f2py_success = double_from_pyobj(&a,a_capi,"coddity.coddity.c_add() 1st argument (a) can't be converted to double"); --- > f2py_success = float_from_pyobj(&a,a_capi,"coddity.coddity.c_add() 1st argument (a) can't be converted to float"); 195c207 < f2py_success = double_from_pyobj(&b,b_capi,"coddity.coddity.c_add() 2nd argument (b) can't be converted to double"); --- > f2py_success = float_from_pyobj(&b,b_capi,"coddity.coddity.c_add() 2nd argument (b) can't be converted to float"); 214c226 < capi_buildvalue = Py_BuildValue("d",c); --- > capi_buildvalue = Py_BuildValue("f",c); 298c310 < s = PyUnicode_FromString("2.0.0.dev0+git20231224.a43c068"); --- > s = PyUnicode_FromString("2.0.0.dev0+git20231222.94d21b0"); 302c314 < "This module 'coddity' is auto-generated with f2py (version:2.0.0.dev0+git20231224.a43c068).\nFunctions:\n" --- > "This module 'coddity' is auto-generated with f2py (version:2.0.0.dev0+git20231222.94d21b0).\nFunctions:\n" 306c318 < s = PyUnicode_FromString("2.0.0.dev0+git20231224.a43c068"); --- > s = PyUnicode_FromString("2.0.0.dev0+git20231222.94d21b0"); For this test case (extracted from the module coddity use iso_c_binding, only: c_double, c_int, c_int64_t implicit none contains subroutine c_add(a, b, c) bind(c, name="c_add") real(c_double), intent(in) :: a, b real(c_double), intent(out) :: c c = a + b end subroutine c_add end module coddity The steps to reproduce this (and other similar errors) is: micromamba activate numpy-dev spin run $SHELL cd gh-25229 # or wherever the file is f2py -m coddity -c coddity.f90 --build-dir blah --backend meson # Modify the files after inspection Another thing to do is to use meld to visually diff whole folders at once, between working and non-working variants. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
@Pranavchiku almost there :) looking good so far!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| needs['int64_t_from_pyobj'] = ['long_from_pyobj'] | ||
| cfuncs['int64_t_from_pyobj'] = """ | ||
| static int | ||
| int64_t_from_pyobj(int64_t* v, PyObject *obj, const char *errmess) { | ||
| long i = 0; | ||
| if (long_from_pyobj(&i, obj, errmess)) { | ||
| *v = (int64_t)i; | ||
| return 1; | ||
| } | ||
| return 0; | ||
| } | ||
| """ |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
@Pranavchiku could you check (in light of the previous comment) which of these need to be explicitly written out and which can be just type cast? I suppose it might be best to just have each one handled explicitly, if only to get the C++ types correct in the function signatures....
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Yes, on it.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done, we already have ones for float/double_complex so I skipped both. I am not sure about how to add it for bool hence skipped it.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thank you @HaoZeke, I'll apply code review by tonight. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Tests pass locally for me. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Based on a discussion at the triage meeting, we decided to close inactive draft PRs that are more than 1 year old. Feel free to open a new PR to continue working on this. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
ENH: Add templates forf2py c functions and handle more C types
There was an error while loading. Please reload this page.