ndpointer(dtype=None,
ndim=None,
shape=None,
flags=None)
| source code
|
Array-checking restype/argtypes.
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
(dtype), number of dimensions (ndim), shape and flags (e.g.
'C_CONTIGUOUS' or 'F_CONTIGUOUS'). If a given array does not satisfy the
specified restrictions, a TypeError is raised.
Example:
clib.somefunc.argtypes = [ndpointer(dtype=float64,
ndim=1,
flags='C_CONTIGUOUS')]
clib.somefunc(array([1,2,3],dtype=float64))
|