Skip to content

Commit

Permalink
TST: Add check for multipliers in data [f2py]
Browse files Browse the repository at this point in the history
Co-authored-by: jncots <jncots@users.noreply.github.com>
  • Loading branch information
2 people authored and charris committed Oct 1, 2023
1 parent 390be3a commit b7bf593
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion numpy/f2py/crackfortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -1459,7 +1459,7 @@ def analyzeline(m, case, line):
# gh-24746
# Runs only if above code fails. Fixes the line
# DATA IVAR1, IVAR2, IVAR3, IVAR4, EVAR5 /4*0,0.0D0/
# by exanding to ['0', '0', '0', '0', '0.0d0']
# by expanding to ['0', '0', '0', '0', '0.0d0']
if any("*" in m for m in matches):
expanded_list = []
for match in matches:
Expand Down
5 changes: 5 additions & 0 deletions numpy/f2py/tests/src/crackfortran/data_multiplier.f
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
BLOCK DATA MYBLK
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
COMMON /MYCOM/ IVAR1, IVAR2, IVAR3, IVAR4, EVAR5
DATA IVAR1, IVAR2, IVAR3, IVAR4, EVAR5 /2*3,2*2,0.0D0/
END
12 changes: 12 additions & 0 deletions numpy/f2py/tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ def test_crackedlines(self):
assert mod[0]['vars']['mydata']['='] == '0'


class TestDataMultiplierF77(util.F2PyTest):
sources = [util.getpath("tests", "src", "crackfortran", "data_multiplier.f")]

# For gh-23276
def test_data_stmts(self):
assert self.module.mycom.ivar1 == 3
assert self.module.mycom.ivar2 == 3
assert self.module.mycom.ivar3 == 2
assert self.module.mycom.ivar4 == 2
assert self.module.mycom.evar5 == 0


class TestDataWithCommentsF77(util.F2PyTest):
sources = [util.getpath("tests", "src", "crackfortran", "data_with_comments.f")]

Expand Down

0 comments on commit b7bf593

Please sign in to comment.