diff options
author | Pearu Peterson <pearu.peterson@gmail.com> | 2021-07-01 17:54:45 +0300 |
---|---|---|
committer | Rohit Goswami <rog32@hi.is> | 2022-06-05 15:19:12 +0000 |
commit | d4e11c7a2eb64861275facb076d47ccd135fa28c (patch) | |
tree | 307e937f15807094ae81b8a78d791bab4526c851 /numpy/f2py/tests/test_docs.py | |
parent | e5fcb9d52c1b9d3c9caf067849ad1bba128c7e17 (diff) | |
download | numpy-d4e11c7a2eb64861275facb076d47ccd135fa28c.tar.gz |
ENH: Support character string arrays
TST: added test for issue #18684
ENH: f2py opens files with correct encoding, fixes #635
TST: added test for issue #6308
TST: added test for issue #4519
TST: added test for issue #3425
ENH: Implement user-defined hooks support for post-processing f2py data structure. Implement character BC hook.
ENH: Add support for detecting utf-16 and utf-32 encodings.
Diffstat (limited to 'numpy/f2py/tests/test_docs.py')
-rw-r--r-- | numpy/f2py/tests/test_docs.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/numpy/f2py/tests/test_docs.py b/numpy/f2py/tests/test_docs.py new file mode 100644 index 000000000..4aa5f5f5c --- /dev/null +++ b/numpy/f2py/tests/test_docs.py @@ -0,0 +1,55 @@ +import os +import pytest +import numpy as np +from numpy.testing import assert_array_equal, assert_equal +from . import util + + +def get_docdir(): + # assuming that documentation tests are run from a source + # directory + return os.path.abspath(os.path.join( + os.path.dirname(__file__), + '..', '..', '..', + 'doc', 'source', 'f2py')) + + +pytestmark = pytest.mark.skipif( + not os.path.isdir(get_docdir()), + reason=('Could not find f2py documentation sources' + f' ({get_docdir()} does not exists)')) + + +def _path(*a): + return os.path.join(*((get_docdir(),) + a)) + + +class TestDocAdvanced(util.F2PyTest): + # options = ['--debug-capi', '--build-dir', '/tmp/build-f2py'] + sources = [_path('asterisk1.f90'), _path('asterisk2.f90'), + _path('ftype.f')] + + def test_asterisk1(self): + foo = getattr(self.module, 'foo1') + assert_equal(foo(), b'123456789A12') + + def test_asterisk2(self): + foo = getattr(self.module, 'foo2') + assert_equal(foo(2), b'12') + assert_equal(foo(12), b'123456789A12') + assert_equal(foo(24), b'123456789A123456789B') + + def test_ftype(self): + ftype = self.module + ftype.foo() + assert_equal(ftype.data.a, 0) + ftype.data.a = 3 + ftype.data.x = [1, 2, 3] + assert_equal(ftype.data.a, 3) + assert_array_equal(ftype.data.x, + np.array([1, 2, 3], dtype=np.float32)) + ftype.data.x[1] = 45 + assert_array_equal(ftype.data.x, + np.array([1, 45, 3], dtype=np.float32)) + + # TODO: implement test methods for other example Fortran codes |