8000 Merge pull request #25361 from HaoZeke/gh25337f2yregre · numpy/numpy@35c4319 · GitHub
[go: up one dir, main page]

Skip to content

Commit 35c4319

Browse files
authored
Merge pull request #25361 from HaoZeke/gh25337f2yregre
BUG: Fix regression with `f2py` wrappers when modules and subroutines are present
2 parents a5b67bb + 0cbdf62 commit 35c4319

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

numpy/f2py/f90mod_rules.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def dadd(line, s=doc):
112112
mfargs.append(n)
113113
outmess('\t\tConstructing F90 module support for "%s"...\n' %
114114
(m['name']))
115-
if m['name'] in usenames:
115+
if m['name'] in usenames and not onlyvars:
116116
outmess(f"\t\t\tSkipping {m['name']} since it is in 'use'...\n")
117117
continue
118118
if onlyvars:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module data
2+
real(8) :: shift
3+
contains
4+
subroutine set_shift(in_shift)
5+
real(8), intent(in) :: in_shift
6+
shift = in_shift
7+
end subroutine set_shift
8+
end module data
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
subroutine shift_a(dim_a, a)
2+
use data, only: shift
3+
integer, intent(in) :: dim_a
4+
real(8), intent(inout), dimension(dim_a) :: a
5+
a = a + shift
6+
end subroutine shift_a

numpy/f2py/tests/test_regression.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,14 @@ def test_include_path():
6464
fnames_in_dir = os.listdir(incdir)
6565
for fname in ("fortranobject.c", "fortranobject.h"):
6666
assert fname in fnames_in_dir
67+
68+
69+
class TestModuleAndSubroutine(util.F2PyTest):
70+
module_name = "example"
71+
sources = [util.getpath("tests", "src", "regression", "gh25337", "data.f90"),
72+
util.getpath("tests", "src", "regression", "gh25337", "use_data.f90")]
73+
74+
@pytest.mark.slow
75+
def test_gh25337(self):
76+
self.module.data.set_shift(3)
77+
assert "data" in dir(self.module)

0 commit comments

Comments
 (0)
0