Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Vous êtes un professionnel et vous avez besoin d'une formation ? Mise en oeuvre d'IHM
avec Qt et PySide6
Voir le programme détaillé
Module « numpy.ctypeslib »

Fonction ndpointer - module numpy.ctypeslib

Signature de la fonction ndpointer

def ndpointer(dtype=None, ndim=None, shape=None, flags=None) 

Description

help(numpy.ctypeslib.ndpointer)

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, 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

Returns
-------
klass : ndpointer type object
    A type object, which is an ``_ndtpr`` instance containing
    dtype, ndim, shape and flags information.

Raises
------
TypeError
    If a given array does not satisfy the specified restrictions.

Examples
--------
>>> 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



Vous êtes un professionnel et vous avez besoin d'une formation ? RAG (Retrieval-Augmented Generation)
et Fine Tuning d'un LLM
Voir le programme détaillé