8000 Merge pull request #27730 from HaoZeke/testGH27167 · numpy/numpy@d6b0387 · GitHub
[go: up one dir, main page]

Skip to content

Commit d6b0387

Browse files
authored
Merge pull request #27730 from HaoZeke/testGH27167
TST: Add an F2PY check for exposing variables without functions
2 parents cd63250 + 9a13a5e commit d6b0387

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
``f2py`` handles multiple modules and exposes variables again
2+
-------------------------------------------------------------
3+
A regression has been fixed which allows F2PY users to expose variables to
4+
Python in modules with only assignments, and also fixes situations where
5+
multiple modules are present within a single source file.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
MODULE MOD_TYPES
2+
INTEGER, PARAMETER :: SP = SELECTED_REAL_KIND(6, 37)
3+
INTEGER, PARAMETER :: DP = SELECTED_REAL_KIND(15, 307)
4+
END MODULE
5+
!
6+
MODULE F_GLOBALS
7+
USE MOD_TYPES
8+
IMPLICIT NONE
9+
INTEGER, PARAMETER :: N_MAX = 16
10+
INTEGER, PARAMETER :: I_MAX = 18
11+
INTEGER, PARAMETER :: J_MAX = 72
12+
REAL(SP) :: XREF
13+
END MODULE F_GLOBALS
14+
!
15+
SUBROUTINE DUMMY ()
16+
!
17+
USE F_GLOBALS
18+
USE MOD_TYPES
19+
IMPLICIT NONE
20+
!
21+
REAL(SP) :: MINIMAL
22+
MINIMAL = 0.01*XREF
23+
RETURN
24+
!
25+
END SUBROUTINE DUMMY

numpy/f2py/tests/test_regression.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,15 @@ def test_gh25784():
151151
)
152152
except ImportError as rerr:
153153
assert "unknown_subroutine_" in str(rerr)
154+
155+
156+
@pytest.mark.slow
157+
class TestAssignmentOnlyModules(util.F2PyTest):
158+
# Ensure that variables are exposed without functions or subroutines in a module
159+
sources = [util.getpath("tests", "src", "regression", "assignOnlyModule.f90")]
160+
161+
@pytest.mark.slow
162+
def test_gh27167(self):
163+
assert (self.module.f_globals.n_max == 16)
164+
assert (self.module.f_globals.i_max == 18)
165+
assert (self.module.f_globals.j_max == 72)

0 commit comments

Comments
 (0)
0