Skip to content

Commit 50785ae

Browse files
authored
Merge pull request numpy#19893 from HaoZeke/f2py_docclean
MAINT,DOC: f2py restructring
2 parents 9ebecee + 5126bb8 commit 50785ae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+678
-622
lines changed

doc/source/f2py/advanced.rst

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,46 @@
1-
======================
2-
Advanced F2PY usages
3-
======================
1+
========================
2+
Advanced F2PY use cases
3+
========================
44

5-
Adding self-written functions to F2PY generated modules
6-
=======================================================
5+
Adding user-defined functions to F2PY generated modules
6+
=========================================================
77

8-
Self-written Python C/API functions can be defined inside
8+
User-defined Python C/API functions can be defined inside
99
signature files using ``usercode`` and ``pymethoddef`` statements
1010
(they must be used inside the ``python module`` block). For
1111
example, the following signature file ``spam.pyf``
1212

13-
.. include:: spam.pyf
13+
.. include:: ./code/spam.pyf
1414
:literal:
1515

1616
wraps the C library function ``system()``::
1717

1818
f2py -c spam.pyf
1919

20-
In Python:
20+
In Python this can then be used as:
2121

22-
.. include:: spam_session.dat
23-
:literal:
24-
25-
Modifying the dictionary of a F2PY generated module
26-
===================================================
22+
.. literalinclude:: ./code/results/spam_session.dat
23+
:language: python
2724

28-
The following example illustrates how to add user-defined
29-
variables to a F2PY generated extension module. Given the following
30-
signature file
25+
Adding user-defined variables
26+
==============================
3127

32-
.. include:: var.pyf
33-
:literal:
28+
The following example illustrates how to add user-defined variables to a F2PY
29+
generated extension module by modifying the dictionary of a F2PY generated
30+
module. Consider the following signature file (compiled with ``f2py -c var.pyf``):
3431

35-
compile it as ``f2py -c var.pyf``.
32+
.. literalinclude:: ./code/var.pyf
33+
:language: fortran
3634

3735
Notice that the second ``usercode`` statement must be defined inside
38-
an ``interface`` block and where the module dictionary is available through
39-
the variable ``d`` (see ``f2py var.pyf``-generated ``varmodule.c`` for
36+
an ``interface`` block and the module dictionary is available through
37+
the variable ``d`` (see ``varmodule.c`` generated by ``f2py var.pyf`` for
4038
additional details).
4139

42-
In Python:
40+
Usage in Python:
4341

44-
.. include:: var_session.dat
45-
:literal:
42+
.. literalinclude:: ./code/results/var_session.dat
43+
:language: python
4644

4745

4846
Dealing with KIND specifiers
@@ -70,7 +68,7 @@ Use the ``--f2cmap`` command-line option to pass the file name to F2PY.
7068
By default, F2PY assumes file name is ``.f2py_f2cmap`` in the current
7169
working directory.
7270

73-
Or more generally, the f2cmap file must contain a dictionary
71+
More generally, the f2cmap file must contain a dictionary
7472
with items::
7573

7674
<Fortran typespec> : {<selector_expr>:<C type>}
@@ -79,7 +77,7 @@ that defines mapping between Fortran type::
7977

8078
<Fortran typespec>([kind=]<selector_expr>)
8179

82-
and the corresponding <C type>. <C type> can be one of the following::
80+
and the corresponding <C type>. The <C type> can be one of the following::
8381

8482
char
8583
signed_char
@@ -94,4 +92,4 @@ and the corresponding <C type>. <C type> can be one of the following::
9492
complex_long_double
9593
string
9694

97-
For more information, see F2Py source code ``numpy/f2py/capi_maps.py``.
95+
For more information, see the F2Py source code ``numpy/f2py/capi_maps.py``.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)