Skip to content

REV: Revert gh-17654 - f2py incorrectly translates dimension declarations. #17715

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

Merged
merged 1 commit into from
Nov 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions numpy/f2py/crackfortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -2177,15 +2177,6 @@ def getlincoef(e, xset): # e = a*x+b ; x in xset
m1 = re_1.match(ee)
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:
a = int(a)
except:
pass
try:
b = int(b)
except:
pass
return a, b, x
except Exception:
pass
Expand Down
22 changes: 0 additions & 22 deletions numpy/f2py/tests/test_crackfortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,25 +86,3 @@ def test_defaultPublic(self, tmp_path):
assert 'public' not in mod['vars']['a']['attrspec']
assert 'private' not in mod['vars']['seta']['attrspec']
assert 'public' in mod['vars']['seta']['attrspec']


class TestArrayDimCalculation(util.F2PyTest):
# Issue gh-8062. Calculations that occur in the dimensions of fortran
# array declarations should be interpreted by f2py as integers not floats.
# Prior to fix, test fails as generated fortran wrapper does not compile.
code = """
function test(n, a)
integer, intent(in) :: n
real(8), intent(out) :: a(0:2*n/2)
integer :: test
a(:) = n
test = 1
endfunction
"""

def test_issue_8062(self):
for n in (5, 11):
_, a = self.module.test(n)
assert(a.shape == (n+1,))
assert_array_equal(a, n)