Download .venv/Lib/site-packages/numpy/f2py/tests/test_pyf_src.py from DrDavis/PythonProject1: direct link, hf CLI and curl.
- Browser
- Download file 1.18 kB
-
https://huggingface.co/DrDavis/PythonProject1/resolve/main/.venv/Lib/site-packages/numpy/f2py/tests/test_pyf_src.py
- Command line
-
hf download hf://DrDavis/PythonProject1/.venv/Lib/site-packages/numpy/f2py/tests/test_pyf_src.py
-
curl -L -o test_pyf_src.py https://huggingface.co/DrDavis/PythonProject1/resolve/main/.venv/Lib/site-packages/numpy/f2py/tests/test_pyf_src.py
1.18 kB
| # This test is ported from numpy.distutils | |
| from numpy.f2py._src_pyf import process_str | |
| from numpy.testing import assert_equal | |
| pyf_src = """ | |
| python module foo | |
| <_rd=real,double precision> | |
| interface | |
| subroutine <s,d>foosub(tol) | |
| <_rd>, intent(in,out) :: tol | |
| end subroutine <s,d>foosub | |
| end interface | |
| end python module foo | |
| """ | |
| expected_pyf = """ | |
| python module foo | |
| interface | |
| subroutine sfoosub(tol) | |
| real, intent(in,out) :: tol | |
| end subroutine sfoosub | |
| subroutine dfoosub(tol) | |
| double precision, intent(in,out) :: tol | |
| end subroutine dfoosub | |
| end interface | |
| end python module foo | |
| """ | |
| def normalize_whitespace(s): | |
| """ | |
| Remove leading and trailing whitespace, and convert internal | |
| stretches of whitespace to a single space. | |
| """ | |
| return ' '.join(s.split()) | |
| def test_from_template(): | |
| """Regression test for gh-10712.""" | |
| pyf = process_str(pyf_src) | |
| normalized_pyf = normalize_whitespace(pyf) | |
| normalized_expected_pyf = normalize_whitespace(expected_pyf) | |
| assert_equal(normalized_pyf, normalized_expected_pyf) | |