diff options
author | Warren Weckesser <warren.weckesser@gmail.com> | 2020-05-18 01:16:18 -0400 |
---|---|---|
committer | Warren Weckesser <warren.weckesser@gmail.com> | 2020-05-18 01:16:18 -0400 |
commit | 38e3ca1382e10c272b2433be9935c24c263aca0b (patch) | |
tree | 70e539cd9e20dbfaf7a482e2c52f2e1d848240dc /doc/source/user | |
parent | 00e76889d0f35de7415bf6967237351972cb44cd (diff) | |
download | numpy-38e3ca1382e10c272b2433be9935c24c263aca0b.tar.gz |
DOC: A few small changes in the "Using Python as Glue" page.
* Fix whitespace in the inputs to Python in the f2py examples.
* Capitalize Python and Fortran consistently.
Diffstat (limited to 'doc/source/user')
-rw-r--r-- | doc/source/user/c-info.python-as-glue.rst | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/doc/source/user/c-info.python-as-glue.rst b/doc/source/user/c-info.python-as-glue.rst index 6904a2fec..1a52b0385 100644 --- a/doc/source/user/c-info.python-as-glue.rst +++ b/doc/source/user/c-info.python-as-glue.rst @@ -163,7 +163,7 @@ be imported from Python:: f2py -c -m add add.f This command leaves a file named add.{ext} in the current directory -(where {ext} is the appropriate extension for a python extension +(where {ext} is the appropriate extension for a Python extension module on your platform --- so, pyd, *etc.* ). This module may then be imported from Python. It will contain a method for each subroutine in add (zadd, cadd, dadd, sadd). The docstring of each method contains @@ -185,7 +185,7 @@ information about how the module method may be called:: Improving the basic interface ----------------------------- -The default interface is a very literal translation of the fortran +The default interface is a very literal translation of the Fortran code into Python. The Fortran array arguments must now be NumPy arrays and the integer argument should be an integer. The interface will attempt to convert all arguments to their required types (and shapes) @@ -194,7 +194,7 @@ about the semantics of the arguments (such that C is an output and n should really match the array sizes), it is possible to abuse this function in ways that can cause Python to crash. For example:: - >>> add.zadd([1,2,3], [1,2], [3,4], 1000) + >>> add.zadd([1, 2, 3], [1, 2], [3, 4], 1000) will cause a program crash on most systems. Under the covers, the lists are being converted to proper arrays but then the underlying add @@ -242,7 +242,7 @@ necessary to tell f2py that the value of n depends on the input a (so that it won't try to create the variable n until the variable a is created). -After modifying ``add.pyf``, the new python module file can be generated +After modifying ``add.pyf``, the new Python module file can be generated by compiling both ``add.f`` and ``add.pyf``:: f2py -c add.pyf add.f @@ -266,7 +266,7 @@ The new interface has docstring:: Now, the function can be called in a much more robust way:: - >>> add.zadd([1,2,3],[4,5,6]) + >>> add.zadd([1, 2, 3], [4, 5, 6]) array([5.+0.j, 7.+0.j, 9.+0.j]) Notice the automatic conversion to the correct format that occurred. @@ -276,7 +276,7 @@ Inserting directives in Fortran source -------------------------------------- The nice interface can also be generated automatically by placing the -variable directives as special comments in the original fortran code. +variable directives as special comments in the original Fortran code. Thus, if I modify the source code to contain: .. code-block:: none @@ -662,7 +662,7 @@ To use ctypes you must 2. Load the shared library. -3. Convert the python objects to ctypes-understood arguments. +3. Convert the Python objects to ctypes-understood arguments. 4. Call the function from the library with the ctypes arguments. |