summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2017-11-15 15:32:31 -0700
committerCharles Harris <charlesr.harris@gmail.com>2017-11-15 18:38:32 -0700
commit012ad9fac3015f52951c5a27c03b8e8bc49713a4 (patch)
tree9ccf704ef1af622604dcc046e755f43a3f24b802
parent0a1069ae98f49ba7fa87a37fc62f0db904265c2c (diff)
downloadnumpy-012ad9fac3015f52951c5a27c03b8e8bc49713a4.tar.gz
TST: Test f2py passing string array to callback.
See #10027.
-rw-r--r--numpy/f2py/tests/test_callback.py34
1 files changed, 32 insertions, 2 deletions
diff --git a/numpy/f2py/tests/test_callback.py b/numpy/f2py/tests/test_callback.py
index cf7427d20..1b9a582ed 100644
--- a/numpy/f2py/tests/test_callback.py
+++ b/numpy/f2py/tests/test_callback.py
@@ -4,7 +4,7 @@ import math
import textwrap
import sys
-from numpy import array
+import numpy as np
from numpy.testing import run_module_suite, assert_, assert_equal, dec
from . import util
@@ -48,6 +48,16 @@ cf2py intent(out) a
a = callback(r)
end
+ subroutine string_callback_array(callback, cu, lencu, a)
+ external callback
+ integer callback
+ integer lencu
+ character*8 cu(lencu)
+ integer a
+cf2py intent(out) a
+
+ a = callback(cu, lencu)
+ end
"""
@dec.slow
@@ -120,7 +130,8 @@ cf2py intent(out) a
r = t(a.mth)
assert_(r == 9, repr(r))
- @dec.knownfailureif(sys.platform=='win32', msg='Fails with MinGW64 Gfortran (Issue #9673)')
+ @dec.knownfailureif(sys.platform=='win32',
+ msg='Fails with MinGW64 Gfortran (Issue #9673)')
def test_string_callback(self):
def callback(code):
@@ -133,6 +144,25 @@ cf2py intent(out) a
r = f(callback)
assert_(r == 0, repr(r))
+ @dec.knownfailureif(sys.platform=='win32',
+ msg='Fails with MinGW64 Gfortran (Issue #9673)')
+ def test_string_callback_array(self):
+ # See gh-10027
+ cu = np.zeros((1, 8), 'S1')
+
+ def callback(cu, lencu):
+ if cu.shape != (lencu, 8):
+ return 1
+ if cu.dtype != 'S1':
+ return 2
+ if not np.all(cu == b''):
+ return 3
+ return 0
+
+ f = getattr(self.module, 'string_callback_array')
+ res = f(callback, cu, len(cu))
+ assert_(res == 0, repr(res))
+
if __name__ == "__main__":
run_module_suite()