Struct numpy::PyArrayDescr [−][src]
pub struct PyArrayDescr(_);
Expand description
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
Returns self
as *mut PyArray_Descr
.
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().unwrap().to_string(), "float64"); });
Returns the data type as DataType
enum.
Trait Implementations
Performs the conversion.
Performs the conversion.
Performs the conversion.
type AsRefTarget = Self
type AsRefTarget = Self
Utility type to make Py::as_ref work
PyTypeObject instance for this type.
Checks if object
is an instance of this type or a subclass of this type.
Checks if object
is an instance of this type.
Auto Trait Implementations
impl !RefUnwindSafe for PyArrayDescr
impl !Send for PyArrayDescr
impl !Sync for PyArrayDescr
impl Unpin for PyArrayDescr
impl UnwindSafe for PyArrayDescr
Blanket Implementations
Mutably borrows from an owned value. Read more
Convert from an arbitrary PyObject
. Read more
Convert from an arbitrary borrowed PyObject
. Read more
Convert from an arbitrary PyObject
or panic. Read more
Convert from an arbitrary PyObject
or panic. Read more
Convert from an arbitrary PyObject
. Read more
Convert from an arbitrary borrowed PyObject
. Read more
Convert from an arbitrary borrowed PyObject
. Read more
Cast from a concrete Python object type to PyObject.
pub fn try_from_exact<V>(value: V) -> Result<&'v T, PyDowncastError<'v>> where
V: Into<&'v PyAny>,
pub fn try_from_exact<V>(value: V) -> Result<&'v T, PyDowncastError<'v>> where
V: Into<&'v PyAny>,
Cast from a concrete Python object type to PyObject. With exact type check.
Returns the safe abstraction over the type object.