-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
BUG: f2py incorrectly translates dimension declarations - part 2. #17687
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
Conversation
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.
@@ -2178,14 +2181,10 @@ def getlincoef(e, xset): # e = a*x+b ; x in xset | |||
c2 = myeval(ee, {}, {}) | |||
if (a * 0.5 + b == c and a * 1.5 + b == c2): | |||
# gh-8062: return integers instead of floats if possible. | |||
try: | |||
if a.is_integer(): |
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.
This will fail if a
is an integer; the same holds for b
.
if a.is_integer(): | |
if isinstance(a, float) and a.is_integer(): |
In [8]: int().is_integer()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-8-d4bbeabb52a2> in <module>
----> 1 int().is_integer()
AttributeError: 'int' object has no attribute 'is_integer'
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.
And what's supposed to happen here if a.is_integer()
evaluates to False
?
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.
Note that int.is_integer
actually does exist in newer versions of python.
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.
Is this a new feature planned for 3.10?
On both 3.8 and 3.9 I'm just getting an AttributeError
.
I am inclined to shelve this PR. If I implement @BvB93's very sensible suggestion then segfaults occur at the end of running the tests or simple standalone examples, and this makes no sense to me. I had categorised the original bug as low-hanging fruit requiring a small localised change, but it has become clear that the situation is much more complicated than this (or at least much more complicated than my understanding of it). The more I look at it, the worse it gets. Two examples: (1) the line numpy/numpy/f2py/crackfortran.py Line 2179 in b219f69
which controls access to the code fix and the return from Hence I am inclined to close this PR as the issue needs further consideration, probably involving a fuller understanding and possible rewrite of |
In a triage review we discussed this. It seems the safe thing to do is to back out gh-17654. The tests here should pass on the old code, right? If so it would be good to keep them. |
Yes please. |
Hopefully we can revisit this after the 1.20 release and do a complete fix |
Corrections to PR gh-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 gh-8062.