pub fn from_vec3<'py>(py: Python<'py>, v: &[Vec<Vec<T>>]) -> Result<&'py Self, FromVecError> {
        let len2 = v.last().map_or(0, |v| v.len());
        if v.iter().any(|v| v.len() != len2) {
            return Err(FromVecError::new(v.len(), len2));
        }
        let len3 = 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() != len3)) {
            return Err(FromVecError::new(v.len(), len3));
        }
        let dims = [v.len(), len2, len3];
        let array = Self::new(py, dims, false);
        unsafe {
            for (z, vz) in v.iter().enumerate() {
                for (y, vzy) in vz.iter().enumerate() {
                    for (x, vzyx) in vzy.iter().enumerate() {
                        *array.uget_mut([z, y, x]) = vzyx.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
/// ```
/// # #[macro_use] extern crate ndarray;
/// use numpy::PyArray;
/// let vec3 = vec![vec![vec![1, 2]; 2]; 2];
/// pyo3::Python::with_gil(|py| {
///     let pyarray = PyArray::from_vec3(py, &vec3).unwrap();
///     assert_eq!(
///         pyarray.readonly().as_array(),
///         array![[[1, 2], [1, 2]], [[1, 2], [1, 2]]]
///     );
///     assert!(PyArray::from_vec3(py, &[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<T>>]) -> Result<&'py Self, FromVecError> {
        let len2 = v.last().map_or(0, |v| v.len());
        if v.iter().any(|v| v.len() != len2) {
            return Err(FromVecError::new(v.len(), len2));
        }
        let len3 = 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() != len3)) {
            return Err(FromVecError::new(v.len(), len3));
        }
        let dims = [v.len(), len2, len3];
        let array = Self::new(py, dims, false);
        unsafe {
            for (z, vz) in v.iter().enumerate() {
                for (y, vzy) in vz.iter().enumerate() {
                    for (x, vzyx) in vzy.iter().enumerate() {
                        *array.uget_mut([z, y, x]) = vzyx.clone();
                    }
                }
            }
        }
        Ok(array)
    }
pub fn from_vec3 < ' py > ( py : Python < ' py > , v : & [ Vec < Vec < T > > ] ) -> Result < & ' py Self , FromVecError > { let len2 = v . last ( ) . map_or ( 0 , | v | v . len ( ) ) ; if v . iter ( ) . any ( | v | v . len ( ) != len2 ) { return Err ( FromVecError :: new ( v . len ( ) , len2 ) ) ; } let len3 = 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 ( ) != len3 ) ) { return Err ( FromVecError :: new ( v . len ( ) , len3 ) ) ; } let dims = [ v . len ( ) , len2 , len3 ] ; let array = Self :: new ( py , dims , false ) ; unsafe { for ( z , vz ) in v . iter ( ) . enumerate ( ) { for ( y , vzy ) in vz . iter ( ) . enumerate ( ) { for ( x , vzyx ) in vzy . iter ( ) . enumerate ( ) { * array . uget_mut ( [ z , y , x ] ) = vzyx . 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<T>>]
example
None
#[macro_use] extern crate ndarray;
None