-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
f2py incorrectly translate dimension declaration #8062
Comments
In fortran functions passed to f2py, calculations that occur in the dimensions of array declarations are interpreted as floats. Valid fortran requires integers. Problem only occurs with fortran functions not subroutines as only for the former does f2py generate fortran wrapper code that fails to compile. Relevant code is in numpy.f2py.crackfortran.getlincoef(), which calculates and returns the coefficients to getarrlen() for writing to the fortran wrapper code. Fixes numpygh-8062.
Corrections to PR numpygh-17654 following post-merge review. Fix now only casts floats to integers if they are definitely integers. Also, division that occurs in fortran array declarations is evaluated in an integer context, so f2py.crackfortran.myeval does the same, converting single to double slashes. Fixed numpygh-8062.
FYI, I am working on implementing a symbolic engine that will allow evaluating the dimension specifications correctly as well as be used in other places where f2py needs to process Fortran expressions. |
ENH: Symbolic solver for dimension specifications.
It seems still a #8062bug persists: the original example still fails either from command line 'f2py' or or from python3:>>>numpy.f2py. Note "... python3-numpy is already the newest version (1:1.17.4-5ubuntu3)...." |
Consider n being an integer and a() is an array The declaration
is converted into:
which is incorrect. Attaching a minimal Fortran 90 example (zipped because I cannot upload
t1.zip
If, in the attached example, you changed n/2*2 into, say, n, the code would compile correctly.
The text was updated successfully, but these errors were encountered: