[][src]Struct numpy::PyArrayDescr

pub struct PyArrayDescr(_);

Binding of numpy.dtype.

Example

use pyo3::types::IntoPyDict;
pyo3::Python::with_gil(|py| {
    let locals = [("np", numpy::get_array_module(py).unwrap())].into_py_dict(py);
    let dtype: &numpy::PyArrayDescr = py
        .eval("np.array([1, 2, 3.0]).dtype", Some(locals), None)
        .unwrap()
        .downcast()
        .unwrap();
    assert_eq!(dtype.get_datatype().unwrap(), numpy::DataType::Float64);
});

Implementations

impl PyArrayDescr[src]

pub fn as_dtype_ptr(&self) -> *mut PyArray_Descr[src]

Returns self as *mut PyArray_Descr.

pub fn get_type(&self) -> &PyType[src]

Returns the internal PyType that this dtype holds.

Example

pyo3::Python::with_gil(|py| {
   let array = numpy::PyArray::from_vec(py, vec![0.0, 1.0, 2.0f64]);
   let dtype = array.dtype();
   assert_eq!(dtype.get_type().name().to_string(), "numpy.float64");
});

pub fn get_datatype(&self) -> Option<DataType>[src]

Returns the data type as DataType enum.

Trait Implementations

impl AsPyPointer for PyArrayDescr[src]

pub fn as_ptr(&self) -> *mut PyObject[src]

Gets the underlying FFI pointer, returns a borrowed pointer.

impl AsRef<PyAny> for PyArrayDescr[src]

impl Debug for PyArrayDescr[src]

impl Deref for PyArrayDescr[src]

type Target = PyAny

The resulting type after dereferencing.

impl Display for PyArrayDescr[src]

impl<'_> From<&'_ PyArrayDescr> for Py<PyArrayDescr>[src]

impl<'a> From<&'a PyArrayDescr> for &'a PyAny[src]

impl<'py> FromPyObject<'py> for &'py PyArrayDescr[src]

impl<'_> IntoPy<Py<PyArrayDescr>> for &'_ PyArrayDescr[src]

impl PartialEq<PyArrayDescr> for PyArrayDescr[src]

impl PyLayout<PyArrayDescr> for PyArray_Descr[src]

impl PyNativeType for PyArrayDescr[src]

impl PyTypeInfo for PyArrayDescr[src]

type Type = ()

Type of objects to store in PyObject struct

type BaseType = PyAny

Base class

type Layout = PyArray_Descr

Layout

type BaseLayout = PyObject

Layout of Basetype.

type Initializer = PyNativeTypeInitializer<Self>

Initializer for layout

type AsRefTarget = Self

Utility type to make Py::as_ref work

impl ToPyObject for PyArrayDescr[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<'p, T> FromPyPointer<'p> for T where
    T: 'p + PyNativeType
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<'v, T> PyTryFrom<'v> for T where
    T: PyTypeInfo + PyNativeType
[src]

impl<T> PyTypeObject for T where
    T: PyTypeInfo
[src]

impl<T> ToBorrowedObject for T where
    T: ToPyObject
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.