pub fn save_in_csv(&self, filepath: &str, transpose: bool) -> Result<(), Box<dyn Error>> {
        let mut wrt = csv::WriterBuilder::new()
            .has_headers(false)
            .from_path(filepath)?;

        // Use star notation just to show that we understand it
        let points = if transpose {
            let mut transposed: Vec<Vec<f64>> =
                vec![Vec::with_capacity(self.nb_active); self.points[0].len()];
            for (i, point) in (*self.points).iter().enumerate() {
                if self.active[i] {
                    for i in 0..point.len() {
                        transposed[i].push(point[i]);
                    }
                }
            }
            transposed
        } else {
            self.points
                .iter()
                .enumerate()
                .filter(|(i, _)| self.active[*i])
                .to_owned()
                .unzip::<usize, &Vec<f64>, Vec<usize>, Vec<&Vec<f64>>>()
                .1
                .iter()
                .map(|x| x.to_owned().to_owned())
                .collect()
        };
        for point in points.iter() {
            wrt.serialize(Record {
                point: point.clone(),
            })?;
        }
        Ok(())
    }
/// Stores a PointSet in a CSV file. This will store in a matrix form the active points in the PointSet.
/// Each row represents an active point, and each column a dimension in the space.
///
/// # Arguments
///
/// * `filepath` - The path to the file where to store the PointSet points.
/// * `transpose` - Transpose the matrix in the output CSV
///
/// # Example
///
/// The following code snippet stores the PointSet *before* running WSP
/// ```
/// let points = wsp::PointSet::init_from_random(100, 10, 51);
///
/// if let Err(err) = points.save_in_csv("wsp.csv", false) {
///     eprintln!("Error writing in CSV: {}", err);
///     std::process::exit(1);
/// }
/// ```
Stores a PointSet in a CSV file. This will store in a matrix form the active points in the PointSet.
Each row represents an active point, and each column a dimension in the space.
Stores a PointSet in a CSV file . This will store in a matrix form the active points in the PointSet . Each row represents an active point and each column a dimension in the space .
pub fn save_in_csv(&self, filepath: &str, transpose: bool) -> Result<(), Box<dyn Error>> {
        let mut wrt = csv::WriterBuilder::new()
            .has_headers(false)
            .from_path(filepath)?;
        // Use star notation just to show that we understand it
        let points = if transpose {
            let mut transposed: Vec<Vec<f64>> =
                vec![Vec::with_capacity(self.nb_active); self.points[0].len()];
            for (i, point) in (*self.points).iter().enumerate() {
                if self.active[i] {
                    for i in 0..point.len() {
                        transposed[i].push(point[i]);
                    }
                }
            }
            transposed
        } else {
            self.points
                .iter()
                .enumerate()
                .filter(|(i, _)| self.active[*i])
                .to_owned()
                .unzip::<usize, &Vec<f64>, Vec<usize>, Vec<&Vec<f64>>>()
                .1
                .iter()
                .map(|x| x.to_owned().to_owned())
                .collect()
        };
        for point in points.iter() {
            wrt.serialize(Record {
                point: point.clone(),
            })?;
        }
        Ok(())
    }
pub fn save_in_csv ( & self , filepath : & str , transpose : bool ) -> Result < ( ) , Box < dyn Error > > { let mut wrt = csv :: WriterBuilder :: new ( ) . has_headers ( false ) . from_path ( filepath ) ? ; // Use star notation just to show that we understand it let points = if transpose { let mut transposed : Vec < Vec < f64 > > = vec ! [ Vec with_capacity ( self nb_active ) self points [ 0 ] len ( ) ] ; for ( i , point ) in ( * self . points ) . iter ( ) . enumerate ( ) { if self . active [ i ] { for i in 0 .. point . len ( ) { transposed [ i ] . push ( point [ i ] ) ; } } } transposed } else { self . points . iter ( ) . enumerate ( ) . filter ( | ( i , _ ) | self . active [ * i ] ) . to_owned ( ) . unzip :: < usize , & Vec < f64 > , Vec < usize > , Vec < & Vec < f64 > > > ( ) . 1 . iter ( ) . map ( | x | x . to_owned ( ) . to_owned ( ) ) . collect ( ) } ; for point in points . iter ( ) { wrt . serialize ( Record { point : point . clone ( ) , } ) ? ; } Ok ( ( ) ) }
Stores a PointSet in a CSV file.
Stores a PointSet in a CSV file .
&self
filepath
&str
transpose
bool
&self
filepath
&str
transpose
bool
example
The following code snippet stores the PointSet *before* running WSP
```
let points = wsp::PointSet::init_from_random(100, 10, 51).

if let Err(err) = points.save_in_csv("wsp.csv", false) {
eprintln!("Error writing in CSV: {}", err);
std::process::exit(1);
}
```
The following code snippet stores the PointSet * before * running WSP ` ` ` let points = wsp :: PointSet :: init_from_random ( 100 10 51 ) . if let Err ( err ) = points . save_in_csv ( " wsp . csv " false ) { eprintln! ( " Error writing in CSV : {} " err ) ; std :: process :: exit ( 1 ) ; } ` ` `