8000 Merge pull request #13335 from eric-wieser/document-ctypeslib · pentschev/numpy@80823c4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 80823c4

Browse files
authored
Merge pull request numpy#13335 from eric-wieser/document-ctypeslib
DOC: Add as_ctypes_type to the documentation
2 parents 37da972 + 271d2dd commit 80823c4

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

doc/release/1.16.1-notes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ Improvements
8080

8181
Further improvements to ``ctypes`` support in ``np.ctypeslib``
8282
--------------------------------------------------------------
83-
A new ``np.ctypeslib.as_ctypes_type`` function has been added, which can be
83+
A new `numpy.ctypeslib.as_ctypes_type` function has been added, which can be
8484
used to converts a `dtype` into a best-guess `ctypes` type. Thanks to this
85-
new function, ``np.ctypeslib.as_ctypes`` now supports a much wider range of
85+
new function, `numpy.ctypeslib.as_ctypes` now supports a much wider range of
8686
array types, including structures, booleans, and integers of non-native
8787
endianness.
8888

doc/release/1.17.0-notes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ lengths has improved and is on par with complex-valued FFTs.
152152

153153
Further improvements to ``ctypes`` support in ``np.ctypeslib``
154154
--------------------------------------------------------------
155-
A new ``np.ctypeslib.as_ctypes_type`` function has been added, which can be
155+
A new `numpy.ctypeslib.as_ctypes_type` function has been added, which can be
156156
used to converts a `dtype` into a best-guess `ctypes` type. Thanks to this
157-
new function, ``np.ctypeslib.as_ctypes`` now supports a much wider range of
157+
new function, `numpy.ctypeslib.as_ctypes` now supports a much wider range of
158158
array types, including structures, booleans, and integers of non-native
159159
endianness.
160160

doc/source/reference/routines.ctypeslib.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ C-Types Foreign Function Interface (:mod:`numpy.ctypeslib`)
88

99
.. autofunction:: as_array
1010
.. autofunction:: as_ctypes
11+
.. autofunction:: as_ctypes_type
1112
.. autofunction:: ctypes_load_library
1213
.. autofunction:: load_library
1314
.. autofunction:: ndpointer

numpy/ctypeslib.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ def _ctype_from_dtype(dtype):
462462

463463

464464
def as_ctypes_type(dtype):
465-
"""
465+
r"""
466466
Convert a dtype into a ctypes type.
467467
468468
Parameters
@@ -472,7 +472,7 @@ def as_ctypes_type(dtype):
472472
473473
Returns
474474
-------
475-
ctypes
475+
ctype
476476
A ctype scalar, union, array, or struct
477477
478478
Raises
@@ -485,13 +485,17 @@ def as_ctypes_type(dtype):
485485
This function does not losslessly round-trip in either direction.
486486
487487
``np.dtype(as_ctypes_type(dt))`` will:
488+
488489
- insert padding fields
489490
- reorder fields to be sorted by offset
490491
- discard field titles
491492
492493
``as_ctypes_type(np.dtype(ctype))`` will:
493-
- discard the class names of ``Structure``s and ``Union``s
494-
- convert single-element ``Union``s into single-element ``Structure``s
494+
495+
- discard the class names of `ctypes.Structure`\ s and
496+
`ctypes.Union`\ s
497+
- convert single-element `ctypes.Union`\ s into single-element
498+
`ctypes.Structure`\ s
495499
- insert padding fields
496500
497501
"""

0 commit comments

Comments
 (0)
0