pub trait PyArrayDescrMethods<'py>: Sealed {
Show 21 methods // Required methods fn as_dtype_ptr(&self) -> *mut PyArray_Descr; fn into_dtype_ptr(self) -> *mut PyArray_Descr; fn is_equiv_to(&self, other: &Self) -> bool; fn typeobj(&self) -> Bound<'py, PyType>; fn base(&self) -> Bound<'py, PyArrayDescr>; fn shape(&self) -> Vec<usize>; fn names(&self) -> Option<Vec<String>>; fn get_field( &self, name: &str ) -> PyResult<(Bound<'py, PyArrayDescr>, usize)>; // Provided methods fn num(&self) -> c_int { ... } fn itemsize(&self) -> usize { ... } fn alignment(&self) -> usize { ... } fn byteorder(&self) -> u8 { ... } fn char(&self) -> u8 { ... } fn kind(&self) -> u8 { ... } fn flags(&self) -> c_char { ... } fn ndim(&self) -> usize { ... } fn has_object(&self) -> bool { ... } fn is_aligned_struct(&self) -> bool { ... } fn has_subarray(&self) -> bool { ... } fn has_fields(&self) -> bool { ... } fn is_native_byteorder(&self) -> Option<bool> { ... }
}
Expand description

Implementation of functionality for PyArrayDescr.

Required Methods§

source

fn as_dtype_ptr(&self) -> *mut PyArray_Descr

Returns self as *mut PyArray_Descr.

source

fn into_dtype_ptr(self) -> *mut PyArray_Descr

Returns self as *mut PyArray_Descr while increasing the reference count.

Useful in cases where the descriptor is stolen by the API.

source

fn is_equiv_to(&self, other: &Self) -> bool

Returns true if two type descriptors are equivalent.

source

fn typeobj(&self) -> Bound<'py, PyType>

Returns the array scalar corresponding to this type descriptor.

Equivalent to numpy.dtype.type.

source

fn base(&self) -> Bound<'py, PyArrayDescr>

Returns the type descriptor for the base element of subarrays, regardless of their dimension or shape.

If the dtype is not a subarray, returns self.

Equivalent to numpy.dtype.base.

source

fn shape(&self) -> Vec<usize>

Returns the shape of the sub-array.

If the dtype is not a sub-array, an empty vector is returned.

Equivalent to numpy.dtype.shape.

source

fn names(&self) -> Option<Vec<String>>

Returns an ordered list of field names, or None if there are no fields.

The names are ordered according to increasing byte offset.

Equivalent to numpy.dtype.names.

source

fn get_field(&self, name: &str) -> PyResult<(Bound<'py, PyArrayDescr>, usize)>

Returns the type descriptor and offset of the field with the given name.

This method will return an error if this type descriptor is not structured, or if it does not contain a field with a given name.

The list of all names can be found via PyArrayDescr::names.

Equivalent to retrieving a single item from numpy.dtype.fields.

Provided Methods§

source

fn num(&self) -> c_int

Returns a unique number for each of the 21 different built-in enumerated types.

These are roughly ordered from least-to-most precision.

Equivalent to numpy.dtype.num.

source

fn itemsize(&self) -> usize

Returns the element size of this type descriptor.

Equivalent to [numpy.dtype.itemsize][dtype-itemsize].

source

fn alignment(&self) -> usize

Returns the required alignment (bytes) of this type descriptor according to the compiler.

Equivalent to numpy.dtype.alignment.

source

fn byteorder(&self) -> u8

Returns an ASCII character indicating the byte-order of this type descriptor object.

All built-in data-type objects have byteorder either = or |.

Equivalent to numpy.dtype.byteorder.

source

fn char(&self) -> u8

Returns a unique ASCII character for each of the 21 different built-in types.

Note that structured data types are categorized as V (void).

Equivalent to numpy.dtype.char.

source

fn kind(&self) -> u8

Returns an ASCII character (one of biufcmMOSUV) identifying the general kind of data.

Note that structured data types are categorized as V (void).

Equivalent to numpy.dtype.kind.

source

fn flags(&self) -> c_char

Returns bit-flags describing how this type descriptor is to be interpreted.

Equivalent to numpy.dtype.flags.

source

fn ndim(&self) -> usize

Returns the number of dimensions if this type descriptor represents a sub-array, and zero otherwise.

Equivalent to numpy.dtype.ndim.

source

fn has_object(&self) -> bool

Returns true if the type descriptor contains any reference-counted objects in any fields or sub-dtypes.

Equivalent to numpy.dtype.hasobject.

source

fn is_aligned_struct(&self) -> bool

Returns true if the type descriptor is a struct which maintains field alignment.

This flag is sticky, so when combining multiple structs together, it is preserved and produces new dtypes which are also aligned.

Equivalent to numpy.dtype.isalignedstruct.

source

fn has_subarray(&self) -> bool

Returns true if the type descriptor is a sub-array.

source

fn has_fields(&self) -> bool

Returns true if the type descriptor is a structured type.

source

fn is_native_byteorder(&self) -> Option<bool>

Returns true if type descriptor byteorder is native, or None if not applicable.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<'py> PyArrayDescrMethods<'py> for Bound<'py, PyArrayDescr>

source§

fn as_dtype_ptr(&self) -> *mut PyArray_Descr

source§

fn into_dtype_ptr(self) -> *mut PyArray_Descr

source§

fn is_equiv_to(&self, other: &Self) -> bool

source§

fn typeobj(&self) -> Bound<'py, PyType>

source§

fn base(&self) -> Bound<'py, PyArrayDescr>

source§

fn shape(&self) -> Vec<usize>

source§

fn names(&self) -> Option<Vec<String>>

source§

fn get_field(&self, name: &str) -> PyResult<(Bound<'py, PyArrayDescr>, usize)>

Implementors§