summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2019-04-15 00:07:33 -0700
committerEric Wieser <wieser.eric@gmail.com>2019-04-15 00:49:23 -0700
commit271d2dd1c6c8c8d29fd90570b187e61743028501 (patch)
treed6b5ad2c2a2610f08b8db61d0998012a687c953d
parentfb425b769bbe4ff4b5a28f58876871414cc8bb12 (diff)
downloadnumpy-271d2dd1c6c8c8d29fd90570b187e61743028501.tar.gz
DOC: Add as_ctypes_type to the documentation
This is mentioned in the release notes, so probably should be discoverable. Change those mentions to links. Fix the docstring to not cause sphinx to emit warnings.
-rw-r--r--doc/release/1.16.1-notes.rst4
-rw-r--r--doc/release/1.17.0-notes.rst4
-rw-r--r--doc/source/reference/routines.ctypeslib.rst1
-rw-r--r--numpy/ctypeslib.py12
4 files changed, 13 insertions, 8 deletions
diff --git a/doc/release/1.16.1-notes.rst b/doc/release/1.16.1-notes.rst
index 2483b1834..2a190ef91 100644
--- a/doc/release/1.16.1-notes.rst
+++ b/doc/release/1.16.1-notes.rst
@@ -80,9 +80,9 @@ Improvements
Further improvements to ``ctypes`` support in ``np.ctypeslib``
--------------------------------------------------------------
-A new ``np.ctypeslib.as_ctypes_type`` function has been added, which can be
+A new `numpy.ctypeslib.as_ctypes_type` function has been added, which can be
used to converts a `dtype` into a best-guess `ctypes` type. Thanks to this
-new function, ``np.ctypeslib.as_ctypes`` now supports a much wider range of
+new function, `numpy.ctypeslib.as_ctypes` now supports a much wider range of
array types, including structures, booleans, and integers of non-native
endianness.
diff --git a/doc/release/1.17.0-notes.rst b/doc/release/1.17.0-notes.rst
index 1155449a7..54980e8b4 100644
--- a/doc/release/1.17.0-notes.rst
+++ b/doc/release/1.17.0-notes.rst
@@ -152,9 +152,9 @@ lengths has improved and is on par with complex-valued FFTs.
Further improvements to ``ctypes`` support in ``np.ctypeslib``
--------------------------------------------------------------
-A new ``np.ctypeslib.as_ctypes_type`` function has been added, which can be
+A new `numpy.ctypeslib.as_ctypes_type` function has been added, which can be
used to converts a `dtype` into a best-guess `ctypes` type. Thanks to this
-new function, ``np.ctypeslib.as_ctypes`` now supports a much wider range of
+new function, `numpy.ctypeslib.as_ctypes` now supports a much wider range of
array types, including structures, booleans, and integers of non-native
endianness.
diff --git a/doc/source/reference/routines.ctypeslib.rst b/doc/source/reference/routines.ctypeslib.rst
index 71b944a63..562638e9c 100644
--- a/doc/source/reference/routines.ctypeslib.rst
+++ b/doc/source/reference/routines.ctypeslib.rst
@@ -8,6 +8,7 @@ C-Types Foreign Function Interface (:mod:`numpy.ctypeslib`)
.. autofunction:: as_array
.. autofunction:: as_ctypes
+.. autofunction:: as_ctypes_type
.. autofunction:: ctypes_load_library
.. autofunction:: load_library
.. autofunction:: ndpointer
diff --git a/numpy/ctypeslib.py b/numpy/ctypeslib.py
index 1967a85b6..55b0d721c 100644
--- a/numpy/ctypeslib.py
+++ b/numpy/ctypeslib.py
@@ -462,7 +462,7 @@ if ctypes is not None:
def as_ctypes_type(dtype):
- """
+ r"""
Convert a dtype into a ctypes type.
Parameters
@@ -472,7 +472,7 @@ if ctypes is not None:
Returns
-------
- ctypes
+ ctype
A ctype scalar, union, array, or struct
Raises
@@ -485,13 +485,17 @@ if ctypes is not None:
This function does not losslessly round-trip in either direction.
``np.dtype(as_ctypes_type(dt))`` will:
+
- insert padding fields
- reorder fields to be sorted by offset
- discard field titles
``as_ctypes_type(np.dtype(ctype))`` will:
- - discard the class names of ``Structure``s and ``Union``s
- - convert single-element ``Union``s into single-element ``Structure``s
+
+ - discard the class names of `ctypes.Structure`\ s and
+ `ctypes.Union`\ s
+ - convert single-element `ctypes.Union`\ s into single-element
+ `ctypes.Structure`\ s
- insert padding fields
"""