pub fn create_empty_mmap<P: AsRef<Path>>(path: P, shape: &[usize]) -> Result<MatFile> {
    let header_nospace = format!("{{'descr': '<f8', 'fortran_order': False, 'shape': ({},{})}}",
        shape[0], shape[1]);
    let virtual_len =
        // Calculating how many bytes we have in the header, so we can get alignment
        header_nospace.len()
        + 6 // The magic string
        + 2 // The version number
        + 2 // An unsigned 2-byte integer for header length
        + 1 ; // Because there will be a \n added
    let padding_needed = (((virtual_len + 15) / 16) * 16) - virtual_len; // to get to the next 16
    
    // Numpy version 1.0
    let mut writer = File::create(path.as_ref())?;
    writer.write_all(b"\x93NUMPY\x01\x00")?;
    writer.write_u16::<LittleEndian>((header_nospace.len()
        + padding_needed
        + 1) // newline
        // Magic string, version number and 2 bytes for the header length number not included.
        as u16
        )?;
    write!(writer, "{}{}\n", header_nospace, " ".repeat(padding_needed))?;
    writer.set_len((virtual_len + padding_needed + shape[0] * shape[1] * 8) as u64)?;
    open_matrix_mmap(path)
}
/// Create an empty array (for filling with mmap)
Create an empty array (for filling with mmap)
Create an empty array ( for filling with mmap )
pub fn create_empty_mmap<P: AsRef<Path>>(path: P, shape: &[usize]) -> Result<MatFile> {
    let header_nospace = format!("{{'descr': '<f8', 'fortran_order': False, 'shape': ({},{})}}",
        shape[0], shape[1]);
    let virtual_len =
        // Calculating how many bytes we have in the header, so we can get alignment
        header_nospace.len()
        + 6 // The magic string
        + 2 // The version number
        + 2 // An unsigned 2-byte integer for header length
        + 1 ; // Because there will be a \n added
    let padding_needed = (((virtual_len + 15) / 16) * 16) - virtual_len; // to get to the next 16
    // Numpy version 1.0
    let mut writer = File::create(path.as_ref())?;
    writer.write_all(b"\x93NUMPY\x01\x00")?;
    writer.write_u16::<LittleEndian>((header_nospace.len()
        + padding_needed
        + 1) // newline
        // Magic string, version number and 2 bytes for the header length number not included.
        as u16
        )?;
    write!(writer, "{}{}\n", header_nospace, " ".repeat(padding_needed))?;
    writer.set_len((virtual_len + padding_needed + shape[0] * shape[1] * 8) as u64)?;
    open_matrix_mmap(path)
}
pub fn create_empty_mmap < P : AsRef < Path > > ( path : P , shape : & [ usize ] ) -> Result < MatFile > { let header_nospace = format ! ( " " shape [ 0 ] shape [ 1 ] ) ; let virtual_len = // Calculating how many bytes we have in the header, so we can get alignment header_nospace . len ( ) + 6 // The magic string + 2 // The version number + 2 // An unsigned 2-byte integer for header length + 1 ; // Because there will be a \n added let padding_needed = ( ( ( virtual_len + 15 ) / 16 ) * 16 ) - virtual_len ; // to get to the next 16 // Numpy version 1.0 let mut writer = File :: create ( path . as_ref ( ) ) ? ; writer . write_all ( b" \x93 \x01 \x00 " ) ? ; writer . write_u16 :: < LittleEndian > ( ( header_nospace . len ( ) + padding_needed + 1 ) // newline // Magic string, version number and 2 bytes for the header length number not included. as u16 ) ? ; write ! ( writer " \n " header_nospace " " repeat ( padding_needed ) ) ? ; writer . set_len ( ( virtual_len + padding_needed + shape [ 0 ] * shape [ 1 ] * 8 ) as u64 ) ? ; open_matrix_mmap ( path ) }
Create an empty array (for filling with mmap)
Create an empty array ( for filling with mmap )
path
P
shape
&[usize]
path
P
shape
&[usize]