[−][src]Trait numpy::convert::IntoPyArray
Covnersion trait from some rust types to PyArray
.
This trait takes self
, which means it holds a pointer to Rust heap, until resize
or other
destructive method is called.
In addition, if you construct PyArray
via this method,
you cannot use some destructive methods like resize
.
Example
use numpy::{PyArray, IntoPyArray}; let gil = pyo3::Python::acquire_gil(); let py_array = vec![1, 2, 3].into_pyarray(gil.python()); assert_eq!(py_array.as_slice(), &[1, 2, 3]); assert!(py_array.resize(100).is_err()); // You can't resize owned-by-rust array.
Associated Types
Loading content...Required methods
fn into_pyarray<'py>(
self,
_: Python<'py>
) -> &'py PyArray<Self::Item, Self::Dim>
self,
_: Python<'py>
) -> &'py PyArray<Self::Item, Self::Dim>
Implementations on Foreign Types
impl<T: TypeNum> IntoPyArray for Box<[T]>
[src]
type Item = T
type Dim = Ix1
fn into_pyarray<'py>(
self,
py: Python<'py>
) -> &'py PyArray<Self::Item, Self::Dim>
[src]
self,
py: Python<'py>
) -> &'py PyArray<Self::Item, Self::Dim>
impl<T: TypeNum> IntoPyArray for Vec<T>
[src]
type Item = T
type Dim = Ix1
fn into_pyarray<'py>(
self,
py: Python<'py>
) -> &'py PyArray<Self::Item, Self::Dim>
[src]
self,
py: Python<'py>
) -> &'py PyArray<Self::Item, Self::Dim>
impl<A, D> IntoPyArray for ArrayBase<OwnedRepr<A>, D> where
A: TypeNum,
D: Dimension,
[src]
A: TypeNum,
D: Dimension,
type Item = A
type Dim = D
fn into_pyarray<'py>(
self,
py: Python<'py>
) -> &'py PyArray<Self::Item, Self::Dim>
[src]
self,
py: Python<'py>
) -> &'py PyArray<Self::Item, Self::Dim>