pub fn from_vec3<'py>(py: Python<'py>, v: &Vec<Vec<Vec<T>>>) -> Result<&'py Self, ErrorKind>
    where
        T: Clone,
    {
        let dim2 = v.last().map_or(0, |v| v.len());
        if v.iter().any(|v| v.len() != dim2) {
            return Err(ErrorKind::FromVec {
                dim1: v.len(),
                dim2,
            });
        }
        let dim3 = v.last().map_or(0, |v| v.last().map_or(0, |v| v.len()));
        if v.iter().any(|v| v.iter().any(|v| v.len() != dim3)) {
            return Err(ErrorKind::FromVec {
                dim1: v.len(),
                dim2: dim3,
            });
        }
        let dims = [v.len(), dim2, dim3];
        let array = Self::new(py, dims, false);
        unsafe {
            for z in 0..v.len() {
                for y in 0..dim2 {
                    for x in 0..dim3 {
                        *array.uget_mut([z, y, x]) = v[z][y][x].clone();
                    }
                }
            }
        }
        Ok(array)
    }
/// Construct a three-dimension PyArray from `Vec<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 error.
///
/// # Example
/// ```
/// # extern crate pyo3; extern crate numpy; #[macro_use] extern crate ndarray; fn main() {
/// use numpy::PyArray;
/// let gil = pyo3::Python::acquire_gil();
/// let vec2 = vec![vec![vec![1, 2]; 2]; 2];
/// let pyarray = PyArray::from_vec3(gil.python(), &vec2).unwrap();
/// assert_eq!(
///     pyarray.as_array(),
///     array![[[1, 2], [1, 2]], [[1, 2], [1, 2]]]
/// );
/// assert!(PyArray::from_vec3(gil.python(), &vec![vec![vec![1], vec![]]]).is_err());
/// # }
/// ```
Construct a three-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 error.
Construct a three - 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 error .
pub fn from_vec3<'py>(py: Python<'py>, v: &Vec<Vec<Vec<T>>>) -> Result<&'py Self, ErrorKind>
    where
        T: Clone,
    {
        let dim2 = v.last().map_or(0, |v| v.len());
        if v.iter().any(|v| v.len() != dim2) {
            return Err(ErrorKind::FromVec {
                dim1: v.len(),
                dim2,
            });
        }
        let dim3 = v.last().map_or(0, |v| v.last().map_or(0, |v| v.len()));
        if v.iter().any(|v| v.iter().any(|v| v.len() != dim3)) {
            return Err(ErrorKind::FromVec {
                dim1: v.len(),
                dim2: dim3,
            });
        }
        let dims = [v.len(), dim2, dim3];
        let array = Self::new(py, dims, false);
        unsafe {
            for z in 0..v.len() {
                for y in 0..dim2 {
                    for x in 0..dim3 {
                        *array.uget_mut([z, y, x]) = v[z][y][x].clone();
                    }
                }
            }
        }
        Ok(array)
    }
pub fn from_vec3 < ' py > ( py : Python < ' py > , v : & Vec < Vec < Vec < T > > > ) -> Result < & ' py Self , ErrorKind > where T : Clone , { let dim2 = v . last ( ) . map_or ( 0 , | v | v . len ( ) ) ; if v . iter ( ) . any ( | v | v . len ( ) != dim2 ) { return Err ( ErrorKind :: FromVec { dim1 : v . len ( ) , dim2 , } ) ; } let dim3 = v . last ( ) . map_or ( 0 , | v | v . last ( ) . map_or ( 0 , | v | v . len ( ) ) ) ; if v . iter ( ) . any ( | v | v . iter ( ) . any ( | v | v . len ( ) != dim3 ) ) { return Err ( ErrorKind :: FromVec { dim1 : v . len ( ) , dim2 : dim3 , } ) ; } let dims = [ v . len ( ) , dim2 , dim3 ] ; let array = Self :: new ( py , dims , false ) ; unsafe { for z in 0 .. v . len ( ) { for y in 0 .. dim2 { for x in 0 .. dim3 { * array . uget_mut ( [ z , y , x ] ) = v [ z ] [ y ] [ x ] . clone ( ) ; } } } } Ok ( array ) }
Construct a three-dimension PyArray from `Vec<Vec<Vec<T>>>`.
Construct a three - dimension PyArray from ` Vec<Vec<Vec<T >>> ` .
py
Python<'py>
v
&Vec<Vec<Vec<T>>>
py
Python<'py>
v
&Vec<Vec<Vec<T>>>
example
None
extern crate pyo3; extern crate numpy; #[macro_use] extern crate ndarray; fn main() {
None
}
None