[−][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}; pyo3::Python::with_gil(|py| { let py_array = vec![1, 2, 3].into_pyarray(py); assert_eq!(py_array.readonly().as_slice().unwrap(), &[1, 2, 3]); assert!(py_array.resize(100).is_err()); // You can't resize owned-by-rust array. });
Associated Types
Loading content...Required methods
Loading content...Implementations on Foreign Types
impl<T: Element> IntoPyArray for Box<[T]>
[src]
type Item = T
type Dim = Ix1
pub 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: Element> IntoPyArray for Vec<T>
[src]
type Item = T
type Dim = Ix1
pub 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: Element,
D: Dimension,
[src]
A: Element,
D: Dimension,
type Item = A
type Dim = D
pub 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>