8000 MAINT: Move files and add links to documentation · asmeurer/numpy@e21392b · GitHub
[go: up one dir, main page]

Skip to content

Commit e21392b

Browse files
committed
MAINT: Move files and add links to documentation
For f2py
1 parent 9228f04 commit e21392b

File tree

5 files changed

+15
-13
lines changed

5 files changed

+15
-13
lines changed

doc/source/f2py/advanced/boilerplating.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,23 @@ Basic example: Addition module
3636
Let us build on the example (from the user guide, :ref:`f2py-examples`) of a
3737
subroutine which takes in two arrays and returns its sum.
3838

39-
.. literalinclude:: ./code/add.f
39+
.. literalinclude:: ./../code/add.f
4040
:language: fortran
4141

4242

4343
We will recast this into modern fortran:
4444

45-
.. literalinclude:: ./code/advanced/boilerplating/src/adder_base.f90
45+
.. literalinclude:: ./../code/advanced/boilerplating/src/adder_base.f90
4646
:language: fortran
4747

4848
We could go on as in the original example, adding intents by hand among other
4949
things, however in production often there are other concerns. For one, we can
5050
template via FYPP the construction of similar functions:
5151

52-
.. literalinclude:: ./code/advanced/boilerplating/src/gen_adder.f90.fypp
52+
.. literalinclude:: ./../code/advanced/boilerplating/src/gen_adder.f90.fypp
5353
:language: fortran
5454

55-
This can be pre-processed by a build tool to generate the full fortran code:
55+
This can be pre-processed to generate the full fortran code:
5656

5757
.. code:: sh
5858
@@ -63,30 +63,30 @@ As to be expected, this can be wrapped by ``f2py`` subsequently.
6363
Now we will consider maintaining the bindings in a separate file. Note the
6464
following basic ``.pyf`` which can be generated for a single subroutine via ``f2py -m adder adder_base.f90 -h adder.pyf``:
6565

66-
.. literalinclude:: ./code/advanced/boilerplating/src/base_adder.pyf
66+
.. literalinclude:: ./../code/advanced/boilerplating/src/base_adder.pyf
6767
:language: fortran
6868

6969
With the docstring:
7070

71-
.. literalinclude:: ./code/advanced/boilerplating/res/base_docstring.dat
71+
.. literalinclude:: ./../code/advanced/boilerplating/res/base_docstring.dat
7272
:language: python
7373

7474
Which is already pretty good. However, ``n`` should never be passed in the first
7575
place so we will make some minor adjustments.
7676

77-
.. literalinclude:: ./code/advanced/boilerplating/src/improved_base_adder.pyf
77+
.. literalinclude:: ./../code/advanced/boilerplating/src/improved_base_adder.pyf
7878
:language: fortran
7979

8080
Which corresponds to:
8181

82-
.. literalinclude:: ./code/advanced/boilerplating/res/improved_docstring.dat
82+
.. literalinclude:: ./../code/advanced/boilerplating/res/improved_docstring.dat
8383
:language: python
8484

8585
Finally, we can template over this in a similar manner, to attain the original
8686
goal of having bindings which make use of ``f2py`` directives and have minimal
8787
spurious repitition.
8888

89-
.. literalinclude:: ./code/advanced/boilerplating/src/adder.pyf.fypp
89+
.. literalinclude:: ./../code/advanced/boilerplating/src/adder.pyf.fypp
9090
:language: fortran
9191

9292
Usage boils down to:
File renamed without changes.

doc/source/f2py/code/advanced/boilerplating/src/adder.pyf.fypp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ python module adder ! in
1515
#:enddef
1616

1717
#:for dtype_prefix, dtype in [('i', 'integer'), ('s', 'real'), ('d', 'real(kind=8)'), ('c', 'complex'), ('z', 'complex(kind=8)')]
18-
@:add_function(${dtype_prefix}$, ${dtype}$)
18+
@:add_subroutine(${dtype_prefix}$, ${dtype}$)
1919
#:endfor
2020
end module adder
2121
end interface

doc/source/f2py/f2py-examples.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ be used as a starting point when wrapping your own code.
88

99
.. note::
1010

11-
The best place to look for examples is the `NumPy issue tracker`_, or the test
12-
cases for ``f2py``
11+
The best place to look for examples is the `NumPy issue tracker`_, or the
12+
test cases for ``f2py``. Some more use cases are in
13+
:ref:`f2py-boilerplating`.
1314

1415
F2PY walkthrough: a basic extension module
1516
------------------------------------------

doc/source/f2py/f2py-reference.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ F2PY reference manual
99
signature-file
1010
python-usage
1111
buildtools/index
12-
advanced
12+
advanced/use_cases.rst
13+
advanced/boilerplating.rst
1314
f2py-testing

0 commit comments

Comments
 (0)
0