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 ? Coder avec une
Intelligence Artificielle
Voir le programme détaillé
Module « numpy.matlib »

Classe « dtype »

Informations générales

Héritage

builtins.object
    dtype

Définition

class dtype(builtins.object):

help(dtype)

dtype(dtype, align=False, copy=False, [metadata])

    Create a data type object.

    A numpy array is homogeneous, and contains elements described by a
    dtype object. A dtype object can be constructed from different
    combinations of fundamental numeric types.

    Parameters
    ----------
    dtype
        Object to be converted to a data type object.
    align : bool, optional
        Add padding to the fields to match what a C compiler would output
        for a similar C-struct. Can be ``True`` only if `obj` is a dictionary
        or a comma-separated string. If a struct dtype is being created,
        this also sets a sticky alignment flag ``isalignedstruct``.
    copy : bool, optional
        Make a new copy of the data-type object. If ``False``, the result
        may just be a reference to a built-in data-type object.
    metadata : dict, optional
        An optional dictionary with dtype metadata.

    See also
    --------
    result_type

    Examples
    --------
    Using array-scalar type:

    >>> import numpy as np
    >>> np.dtype(np.int16)
    dtype('int16')

    Structured type, one field name 'f1', containing int16:

    >>> np.dtype([('f1', np.int16)])
    dtype([('f1', '<i2')])

    Structured type, one field named 'f1', in itself containing a structured
    type with one field:

    >>> np.dtype([('f1', [('f1', np.int16)])])
    dtype([('f1', [('f1', '<i2')])])

    Structured type, two fields: the first field contains an unsigned int, the
    second an int32:

    >>> np.dtype([('f1', np.uint64), ('f2', np.int32)])
    dtype([('f1', '<u8'), ('f2', '<i4')])

    Using array-protocol type strings:

    >>> np.dtype([('a','f8'),('b','S10')])
    dtype([('a', '<f8'), ('b', 'S10')])

    Using comma-separated field formats.  The shape is (2,3):

    >>> np.dtype("i4, (2,3)f8")
    dtype([('f0', '<i4'), ('f1', '<f8', (2, 3))])

    Using tuples.  ``int`` is a fixed type, 3 the field's shape.  ``void``
    is a flexible type, here of size 10:

    >>> np.dtype([('hello',(np.int64,3)),('world',np.void,10)])
    dtype([('hello', '<i8', (3,)), ('world', 'V10')])

    Subdivide ``int16`` into 2 ``int8``'s, called x and y.  0 and 1 are
    the offsets in bytes:

    >>> np.dtype((np.int16, {'x':(np.int8,0), 'y':(np.int8,1)}))
    dtype((numpy.int16, [('x', 'i1'), ('y', 'i1')]))

    Using dictionaries.  Two fields named 'gender' and 'age':

    >>> np.dtype({'names':['gender','age'], 'formats':['S1',np.uint8]})
    dtype([('gender', 'S1'), ('age', 'u1')])

    Offsets in bytes, here 0 and 25:

    >>> np.dtype({'surname':('S25',0),'age':(np.uint8,25)})
    dtype([('surname', 'S25'), ('age', 'u1')])

Constructeur(s)

Signature du constructeur Description
__new__(*args, **kwargs) Create and return a new object. See help(type) for accurate signature. [extrait de __new__.__doc__]
__init__(self, /, *args, **kwargs) Initialize self. See help(type(self)) for accurate signature. [extrait de __init__.__doc__]

Liste des attributs statiques

Nom de l'attribut Valeur
alignment<member 'alignment' of 'numpy.dtype' objects>
base<attribute 'base' of 'numpy.dtype' objects>
byteorder<member 'byteorder' of 'numpy.dtype' objects>
char<member 'char' of 'numpy.dtype' objects>
descr<attribute 'descr' of 'numpy.dtype' objects>
fields<attribute 'fields' of 'numpy.dtype' objects>
flags<member 'flags' of 'numpy.dtype' objects>
hasobject<attribute 'hasobject' of 'numpy.dtype' objects>
isalignedstruct<attribute 'isalignedstruct' of 'numpy.dtype' objects>
isbuiltin<attribute 'isbuiltin' of 'numpy.dtype' objects>
isnative<attribute 'isnative' of 'numpy.dtype' objects>
itemsize<member 'itemsize' of 'numpy.dtype' objects>
kind<member 'kind' of 'numpy.dtype' objects>
metadata<attribute 'metadata' of 'numpy.dtype' objects>
name<attribute 'name' of 'numpy.dtype' objects>
names<attribute 'names' of 'numpy.dtype' objects>
ndim<attribute 'ndim' of 'numpy.dtype' objects>
num<member 'num' of 'numpy.dtype' objects>
shape<attribute 'shape' of 'numpy.dtype' objects>
str<attribute 'str' of 'numpy.dtype' objects>
subdtype<attribute 'subdtype' of 'numpy.dtype' objects>
typeNone

Liste des opérateurs

Signature de l'opérateur Description
__eq__(self, value) Return self==value. [extrait de __eq__.__doc__]
__ge__(self, value) Return self>=value. [extrait de __ge__.__doc__]
__getitem__(self, key) Return self[key]. [extrait de __getitem__.__doc__]
__gt__(self, value) Return self>value. [extrait de __gt__.__doc__]
__le__(self, value) Return self<=value. [extrait de __le__.__doc__]
__lt__(self, value) Return self<value. [extrait de __lt__.__doc__]
__mul__(self, value) Return self*value. [extrait de __mul__.__doc__]
__ne__(self, value) Return self!=value. [extrait de __ne__.__doc__]
__rmul__(self, value) Return value*self. [extrait de __rmul__.__doc__]

Liste des méthodes

Toutes les méthodes Méthodes d'instance Méthodes statiques Méthodes dépréciées
Signature de la méthodeDescription
__bool__(self) True if self else False [extrait de __bool__.__doc__]
__class_getitem__(object) __class_getitem__(item, /) [extrait de __class_getitem__.__doc__]
__hash__(self) Return hash(self). [extrait de __hash__.__doc__]
__len__(self) Return len(self). [extrait de __len__.__doc__]
__reduce__
__repr__(self) Return repr(self). [extrait de __repr__.__doc__]
__setstate__
__str__(self) Return str(self). [extrait de __str__.__doc__]
newbyteorder newbyteorder(new_order='S', /) [extrait de newbyteorder.__doc__]

Méthodes héritées de la classe object

__delattr__, __dir__, __format__, __getattribute__, __getstate__, __init_subclass__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

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é