create_new_npy

Function create_new_npy 

Source
pub fn create_new_npy<P, T>(path: P, array: &T) -> Result<(), WriteNpyError>
where P: AsRef<Path>, T: WriteNpyExt + ?Sized,
Expand description

Writes an array to a new .npy file at the specified path; error if the file exists.

This is a convenience function for BufWriter::new(File::create_new(path)?) followed by WriteNpyExt::write_npy.

ยงExample

use ndarray::array;
use ndarray_npy::create_new_npy;

let arr = array![[1, 2, 3], [4, 5, 6]];
create_new_npy("new_array.npy", &arr)?;
assert!(create_new_npy("new_array.npy", &arr).is_err());