1
1
from __future__ import division , absolute_import , print_function
2
2
3
3
import math
4
+ import sys
4
5
import textwrap
5
6
6
- from numpy import array
7
+ import numpy as np
7
8
from numpy .testing import run_module_suite , assert_ , assert_equal , dec
8
9
import util
9
10
@@ -47,6 +48,16 @@ class TestF77Callback(util.F2PyTest):
47
48
a = callback(r)
48
49
end
49
50
51
+ subroutine string_callback_array(callback, cu, lencu, a)
52
+ external callback
53
+ integer callback
54
+ integer lencu
55
+ character*8 cu(lencu)
56
+ integer a
57
+ cf2py intent(out) a
58
+
59
+ a = callback(cu, lencu)
60
+ end
50
61
"""
51
62
52
63
@dec .slow
@@ -119,6 +130,8 @@ def mth(self):
119
130
r = t (a .mth )
120
131
assert_ (r == 9 , repr (r ))
121
132
133
+ @dec .knownfailureif (sys .platform == 'win32' ,
134
+ msg = 'Fails with MinGW64 Gfortran (Issue #9673)' )
122
135
def test_string_callback (self ):
123
136
124
137
def callback (code ):
@@ -131,6 +144,25 @@ def callback(code):
131
144
r = f (callback )
132
145
assert_ (r == 0 , repr (r ))
133
146
147
+ @dec .knownfailureif (sys .platform == 'win32' ,
148
+ msg = 'Fails with MinGW64 Gfortran (Issue #9673)' )
149
+ def test_string_callback_array (self ):
150
+ # See gh-10027
151
+ cu = np .zeros ((1 , 8 ), 'S1' )
152
+
153
+ def callback (cu , lencu ):
154
+ if cu .shape != (lencu , 8 ):
155
+ return 1
156
+ if cu .dtype != 'S1' :
157
+ return 2
158
+ if not np .all (cu == b'' ):
159
+ return 3
160
+ return 0
161
+
162
+ f = getattr (self .module , 'string_callback_array' )
163
+ res = f (callback , cu , len (cu ))
164
+ assert_ (res == 0 , repr (res ))
165
+
134
166
135
167
if __name__ == "__main__" :
136
168
run_module_suite ()
0 commit comments