numpy 1.22.4 Pypi GitHub Homepage
Other Docs
ParametersRaisesReturnsBackRef
ndpointer(dtype=None, ndim=None, shape=None, flags=None)

An ndpointer instance is used to describe an ndarray in restypes and argtypes specifications. This approach is more flexible than using, for example, POINTER(c_double) , since several restrictions can be specified, which are verified upon calling the ctypes function. These include data type, number of dimensions, shape and flags. If a given array does not satisfy the specified restrictions, a TypeError is raised.

Parameters

dtype : data-type, optional

Array data-type.

ndim : int, optional

Number of array dimensions.

shape : tuple of ints, optional

Array shape.

flags : str or tuple of str

Array flags; may be one or more of:

  • C_CONTIGUOUS / C / CONTIGUOUS

  • F_CONTIGUOUS / F / FORTRAN

  • OWNDATA / O

  • WRITEABLE / W

  • ALIGNED / A

  • WRITEBACKIFCOPY / X

  • UPDATEIFCOPY / U

Raises

TypeError

If a given array does not satisfy the specified restrictions.

Returns

klass : ndpointer type object

A type object, which is an _ndtpr instance containing dtype, ndim, shape and flags information.

Array-checking restype/argtypes.

Examples

This example is valid syntax, but we were not able to check execution
>>> clib.somefunc.argtypes = [np.ctypeslib.ndpointer(dtype=np.float64,
...  ndim=1,
...  flags='C_CONTIGUOUS')]
... #doctest: +SKIP
... clib.somefunc(np.array([1, 2, 3], dtype=np.float64))
... #doctest: +SKIP
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

numpy.ctypeslib

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /numpy/ctypeslib.py#235
type: <class 'function'>
Commit: