OXIESEC PANEL
- Current Dir:
/
/
usr
/
local
/
lib
/
python3.6
/
dist-packages
/
numpy
/
f2py
/
tests
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
10/28/2024 05:59:26 AM
rwxr-xr-x
📄
__init__.py
0 bytes
10/28/2024 05:59:24 AM
rw-r--r--
📁
__pycache__
-
10/28/2024 05:59:26 AM
rwxr-xr-x
📁
src
-
10/28/2024 05:59:26 AM
rwxr-xr-x
📄
test_array_from_pyobj.py
21.46 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_assumed_shape.py
1.55 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_block_docstring.py
621 bytes
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_callback.py
3.89 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_common.py
802 bytes
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_compile_function.py
4.21 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_crackfortran.py
2.73 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_kind.py
1012 bytes
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_mixed.py
911 bytes
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_parameter.py
3.82 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_quoted_character.py
927 bytes
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_regression.py
698 bytes
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_return_character.py
3.83 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_return_complex.py
4.51 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_return_integer.py
4.47 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_return_logical.py
4.73 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_return_real.py
5.28 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_semicolon_split.py
1.48 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_size.py
1.26 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_string.py
610 bytes
10/28/2024 05:59:24 AM
rw-r--r--
📄
util.py
9.39 KB
10/28/2024 05:59:24 AM
rw-r--r--
Editing: test_callback.py
Close
import math import textwrap import sys import pytest import numpy as np from numpy.testing import assert_, assert_equal, IS_PYPY from . import util class TestF77Callback(util.F2PyTest): code = """ subroutine t(fun,a) integer a cf2py intent(out) a external fun call fun(a) end subroutine func(a) cf2py intent(in,out) a integer a a = a + 11 end subroutine func0(a) cf2py intent(out) a integer a a = 11 end subroutine t2(a) cf2py intent(callback) fun integer a cf2py intent(out) a external fun call fun(a) end subroutine string_callback(callback, a) external callback double precision callback double precision a character*1 r cf2py intent(out) a r = 'r' 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 """ @pytest.mark.parametrize('name', 't,t2'.split(',')) def test_all(self, name): self.check_function(name) @pytest.mark.xfail(IS_PYPY, reason="PyPy cannot modify tp_doc after PyType_Ready") def test_docstring(self): expected = textwrap.dedent("""\ a = t(fun,[fun_extra_args]) Wrapper for ``t``. Parameters ---------- fun : call-back function Other Parameters ---------------- fun_extra_args : input tuple, optional Default: () Returns ------- a : int Notes ----- Call-back functions:: def fun(): return a Return objects: a : int """) assert_equal(self.module.t.__doc__, expected) def check_function(self, name): t = getattr(self.module, name) r = t(lambda: 4) assert_(r == 4, repr(r)) r = t(lambda a: 5, fun_extra_args=(6,)) assert_(r == 5, repr(r)) r = t(lambda a: a, fun_extra_args=(6,)) assert_(r == 6, repr(r)) r = t(lambda a: 5 + a, fun_extra_args=(7,)) assert_(r == 12, repr(r)) r = t(lambda a: math.degrees(a), fun_extra_args=(math.pi,)) assert_(r == 180, repr(r)) r = t(math.degrees, fun_extra_args=(math.pi,)) assert_(r == 180, repr(r)) r = t(self.module.func, fun_extra_args=(6,)) assert_(r == 17, repr(r)) r = t(self.module.func0) assert_(r == 11, repr(r)) r = t(self.module.func0._cpointer) assert_(r == 11, repr(r)) class A: def __call__(self): return 7 def mth(self): return 9 a = A() r = t(a) assert_(r == 7, repr(r)) r = t(a.mth) assert_(r == 9, repr(r)) @pytest.mark.skipif(sys.platform=='win32', reason='Fails with MinGW64 Gfortran (Issue #9673)') def test_string_callback(self): def callback(code): if code == 'r': return 0 else: return 1 f = getattr(self.module, 'string_callback') r = f(callback) assert_(r == 0, repr(r)) @pytest.mark.skipif(sys.platform=='win32', reason='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))