pub fn from_vec2<'py>(py: Python<'py>, v: &[Vec<T>]) -> Result<&'py Self, FromVecError> {
        let last_len = v.last().map_or(0, |v| v.len());
        if v.iter().any(|v| v.len() != last_len) {
            return Err(FromVecError::new(v.len(), last_len));
        }
        let dims = [v.len(), last_len];
        let array = Self::new(py, dims, false);
        unsafe {
            for (y, vy) in v.iter().enumerate() {
                for (x, vyx) in vy.iter().enumerate() {
                    *array.uget_mut([y, x]) = vyx.clone();
                }
            }
        }
        Ok(array)
    }
/// Construct a two-dimension PyArray from `Vec<Vec<T>>`.
///
/// This function checks all dimension of inner vec, and if there's any vec
/// where its dimension differs from others, it returns `ArrayCastError`.
///
/// # Example
/// ```
/// # #[macro_use] extern crate ndarray;
/// use numpy::PyArray;
/// let vec2 = vec![vec![1, 2, 3]; 2];
/// pyo3::Python::with_gil(|py| {
///     let pyarray = PyArray::from_vec2(py, &vec2).unwrap();
///     assert_eq!(pyarray.readonly().as_array(), array![[1, 2, 3], [1, 2, 3]]);
///     assert!(PyArray::from_vec2(py, &[vec![1], vec![2, 3]]).is_err());
/// });
/// ```
Construct a two-dimension PyArray from `Vec>`.
This function checks all dimension of inner vec, and if there's any vec
where its dimension differs from others, it returns `ArrayCastError`.
Construct a two - dimension PyArray from ` Vec > ` . This function checks all dimension of inner vec and if there ' s any vec where its dimension differs from others it returns ` ArrayCastError ` .
pub fn from_vec2<'py>(py: Python<'py>, v: &[Vec<T>]) -> Result<&'py Self, FromVecError> {
        let last_len = v.last().map_or(0, |v| v.len());
        if v.iter().any(|v| v.len() != last_len) {
            return Err(FromVecError::new(v.len(), last_len));
        }
        let dims = [v.len(), last_len];
        let array = Self::new(py, dims, false);
        unsafe {
            for (y, vy) in v.iter().enumerate() {
                for (x, vyx) in vy.iter().enumerate() {
                    *array.uget_mut([y, x]) = vyx.clone();
                }
            }
        }
        Ok(array)
    }
pub fn from_vec2 < ' py > ( py : Python < ' py > , v : & [ Vec < T > ] ) -> Result < & ' py Self , FromVecError > { let last_len = v . last ( ) . map_or ( 0 , | v | v . len ( ) ) ; if v . iter ( ) . any ( | v | v . len ( ) != last_len ) { return Err ( FromVecError :: new ( v . len ( ) , last_len ) ) ; } let dims = [ v . len ( ) , last_len ] ; let array = Self :: new ( py , dims , false ) ; unsafe { for ( y , vy ) in v . iter ( ) . enumerate ( ) { for ( x , vyx ) in vy . iter ( ) . enumerate ( ) { * array . uget_mut ( [ y , x ] ) = vyx . clone ( ) ; } } } Ok ( array ) }
Construct a two-dimension PyArray from `Vec<Vec<T>>`.
Construct a two - dimension PyArray from ` Vec<Vec<T >> ` .
py
Python<'py>
v
&[Vec<T>]
example
None
#[macro_use] extern crate ndarray;
None