[][src]Trait numpy::convert::IntoPyArray

pub trait IntoPyArray {
    type Item: TypeNum;
    type Dim: Dimension;
    fn into_pyarray<'py>(
        self,
        _: Python<'py>
    ) -> &'py PyArray<Self::Item, Self::Dim>; }

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>

Loading content...

Implementations on Foreign Types

impl<T: TypeNum> IntoPyArray for Box<[T]>[src]

type Item = T

type Dim = Ix1

impl<T: TypeNum> IntoPyArray for Vec<T>[src]

type Item = T

type Dim = Ix1

impl<A, D> IntoPyArray for ArrayBase<OwnedRepr<A>, D> where
    A: TypeNum,
    D: Dimension
[src]

type Item = A

type Dim = D

Loading content...

Implementors

Loading content...