Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dbd96e9

Browse files
HaoZekecharris
authored andcommitted
TST: Add one for gh25211
1 parent 3ab268d commit dbd96e9

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
SUBROUTINE FOO(FUN,R)
2+
EXTERNAL FUN
3+
INTEGER I
4+
REAL*8 R, FUN
5+
Cf2py intent(out) r
6+
R = 0D0
7+
DO I=-5,5
8+
R = R + FUN(I)
9+
ENDDO
10+
END
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
python module __user__routines
2+
interface
3+
function fun(i) result (r)
4+
integer :: i
5+
real*8 :: r
6+
end function fun
7+
end interface
8+
end python module __user__routines
9+
10+
python module callback2
11+
interface
12+
subroutine foo(f,r)
13+
use __user__routines, f=>fun
14+
external f
15+
real*8 intent(out) :: r
16+
end subroutine foo
17+
end interface
18+
end python module callback2

numpy/f2py/tests/test_callback.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,16 @@ def foo(x):
228228

229229
r = self.module.gh18335(foo)
230230
assert r == 123 + 1
231+
232+
233+
class TestGH25211(util.F2PyTest):
234+
sources = [util.getpath("tests", "src", "callback", "gh25211.f"),
235+
util.getpath("tests", "src", "callback", "gh25211.pyf")]
236+
module_name = "callback2"
237+
238+
def test_gh18335(self):
239+
def bar(x):
240+
return x*x
241+
242+
res = self.module.foo(bar)
243+
assert res == 110

0 commit comments

Comments
 (0)