Skip to content

Commit 22bbc2c

Browse files
committed
TST: Multiple modules in single pyf for numpygh-27622
1 parent bd1f606 commit 22bbc2c

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module datonly
2+
implicit none
3+
integer, parameter :: max_value = 100
4+
real, dimension(:), allocatable :: data_array
5+
end module datonly
6+
7+
module dat
8+
implicit none
9+
integer, parameter :: max_= 1009
10+
end module dat
11+
12+
subroutine simple_subroutine(ain, aout)
13+
use dat, only: max_
14+
integer, intent(in) :: ain
15+
integer, intent(out) :: aout
16+
aout = ain + max_
17+
end subroutine simple_subroutine

numpy/f2py/tests/test_regression.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ def test_inout(self):
2424
assert np.allclose(x, [3, 1, 2])
2525

2626

27+
class TestDataOnlyMultiModule(util.F2PyTest):
28+
# Check that modules without subroutines work
29+
sources = [util.getpath("tests", "src", "regression", "datonly.f90")]
30+
31+
@pytest.mark.slow
32+
def test_mdat(self):
33+
assert self.module.datonly.max_value == 100
34+
assert self.module.dat.max_ == 1009
35+
int_in = 5
36+
assert self.module.simple_subroutine(5) == 1014
37+
38+
2739
class TestNegativeBounds(util.F2PyTest):
2840
# Check that negative bounds work correctly
2941
sources = [util.getpath("tests", "src", "negative_bounds", "issue_20853.f90")]

0 commit comments

Comments
 (0)