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

Gets the underlying FFI pointer, returns a borrowed pointer.

Performs the conversion.

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Extracts Self from the source PyObject.

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Returns a GIL marker constrained to the lifetime of this type.

Cast &PyAny to &Self without no type checking. Read more

Utility type to make Py::as_ref work

Class name

Module name, if any

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.

Converts self into a Python object.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

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

Convert from an arbitrary borrowed PyObject. Read more

Performs the conversion.

Cast from a concrete Python object type to PyObject.

Cast from a concrete Python object type to PyObject. With exact type check.

Cast a PyAny to a specific type of PyObject. The caller must have already verified the reference is for this type. Read more

Returns the safe abstraction over the type object.

Converts self into a Python object and calls the specified closure on the native FFI pointer underlying the Python object. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.