Struct numpy::array::PyArray
[−]
[src]
pub struct PyArray(_);
Untyped safe interface for NumPy ndarray.
Methods
impl PyArray
[src]
fn as_ptr(&self) -> *mut PyArrayObject
fn steal_ptr(self) -> *mut PyArrayObject
unsafe fn from_owned_ptr(py: Python, ptr: *mut PyObject) -> Self
unsafe fn from_borrowed_ptr(py: Python, ptr: *mut PyObject) -> Self
fn ndim(&self) -> usize
The number of dimensions in the array
https://docs.scipy.org/doc/numpy/reference/c-api.array.html#c.PyArray_NDIM
fn dims(&self) -> Vec<usize>
dimensions of the array
https://docs.scipy.org/doc/numpy/reference/c-api.array.html#c.PyArray_DIMS
fn len(&self) -> usize
fn shape(&self) -> Vec<usize>
A synonym for PyArray_DIMS, named to be consistent with the ‘shape’ usage within Python.
fn strides(&self) -> Vec<isize>
The number of elements matches the number of dimensions of the array
fn typenum(&self) -> i32
fn as_array<A: TypeNum>(&self) -> Result<ArrayViewD<A>, ArrayCastError>
Get data as a ndarray::ArrayView
fn as_array_mut<A: TypeNum>(&self) -> Result<ArrayViewMutD<A>, ArrayCastError>
Get data as a ndarray::ArrayViewMut
fn as_slice<A: TypeNum>(&self) -> Result<&[A], ArrayCastError>
Get data as a Rust immutable slice
fn as_slice_mut<A: TypeNum>(&self) -> Result<&mut [A], ArrayCastError>
Get data as a Rust mutable slice
unsafe fn new_<T: TypeNum>(
py: Python,
np: &PyArrayModule,
dims: &[usize],
strides: *mut npy_intp,
data: *mut c_void
) -> Self
py: Python,
np: &PyArrayModule,
dims: &[usize],
strides: *mut npy_intp,
data: *mut c_void
) -> Self
fn new<T: TypeNum>(py: Python, np: &PyArrayModule, dims: &[usize]) -> Self
a wrapper of PyArray_SimpleNew
fn zeros<T: TypeNum>(
py: Python,
np: &PyArrayModule,
dims: &[usize],
order: NPY_ORDER
) -> Self
py: Python,
np: &PyArrayModule,
dims: &[usize],
order: NPY_ORDER
) -> Self
a wrapper of PyArray_ZEROS
fn arange<T: TypeNum>(
py: Python,
np: &PyArrayModule,
start: f64,
stop: f64,
step: f64
) -> Self
py: Python,
np: &PyArrayModule,
start: f64,
stop: f64,
step: f64
) -> Self
a wrapper of PyArray_Arange
Trait Implementations
impl<'source> FromPyObject<'source> for PyArray
[src]
fn extract(py: Python, obj: &'source PyObject) -> PyResult<Self>
Extracts Self
from the source PyObject
.
impl<'source> FromPyObject<'source> for &'source PyArray
[src]
fn extract(py: Python, obj: &'source PyObject) -> PyResult<Self>
Extracts Self
from the source PyObject
.
impl ToPyObject for PyArray
[src]
type ObjectType = Self
fn to_py_object(&self, py: Python) -> Self
Converts self into a Python object.
fn into_py_object(self, py: Python) -> Self::ObjectType
Converts self into a Python object. Read more
fn with_borrowed_ptr<F, R>(&self, py: Python, f: F) -> R where
F: FnOnce(*mut PyObject) -> R,
F: FnOnce(*mut PyObject) -> R,
Converts self into a Python object and calls the specified closure on the native FFI pointer underlying the Python object. Read more
impl PythonObject for PyArray
[src]
fn as_object(&self) -> &PyObject
Casts the Python object to PyObject.
fn into_object(self) -> PyObject
Casts the Python object to PyObject.
unsafe fn unchecked_downcast_from(obj: PyObject) -> Self
Unchecked downcast from PyObject to Self. Undefined behavior if the input object does not have the expected type. Read more
unsafe fn unchecked_downcast_borrow_from<'a>(obj: &'a PyObject) -> &'a Self
Unchecked downcast from PyObject to Self. Undefined behavior if the input object does not have the expected type. Read more
impl PythonObjectWithCheckedDowncast for PyArray
[src]
fn downcast_from<'p>(
py: Python<'p>,
obj: PyObject
) -> Result<PyArray, PythonObjectDowncastError<'p>>
py: Python<'p>,
obj: PyObject
) -> Result<PyArray, PythonObjectDowncastError<'p>>
Cast from PyObject to a concrete Python object type.
fn downcast_borrow_from<'a, 'p>(
py: Python<'p>,
obj: &'a PyObject
) -> Result<&'a PyArray, PythonObjectDowncastError<'p>>
py: Python<'p>,
obj: &'a PyObject
) -> Result<&'a PyArray, PythonObjectDowncastError<'p>>
Cast from PyObject to a concrete Python object type.