def _array_to_file(arr, outfile):
 if isfile(outfile):
  write = (lambda a, f: a.tofile(f))
 else:
  write = _array_to_file_like
 if ((sys.platform == 'darwin') and (arr.nbytes >= (_OSX_WRITE_LIMIT + 1)) and ((arr.nbytes % 4096) == 0)):
  chunksize = (_OSX_WRITE_LIMIT // arr.itemsize)
 elif sys.platform.startswith('win'):
  chunksize = (_WIN_WRITE_LIMIT // arr.itemsize)
 else:
  return write(arr, outfile)
 idx = 0
 arr = arr.view(np.ndarray).flatten()
 while (idx < arr.nbytes):
  write(arr[idx:(idx + chunksize)], outfile)
  idx += chunksize

def _array_to_file ( arr , outfile ) : if isfile ( outfile ) : write = ( lambda a , f : a . tofile ( f ) ) else : write = _array_to_file_like if ( ( sys . platform == 'darwin' ) and ( arr . nbytes >= ( _OSX_WRITE_LIMIT + 1 ) ) and ( ( arr . nbytes % 4096 ) == 0 ) ) : chunksize = ( _OSX_WRITE_LIMIT // arr . itemsize ) elif sys . platform . startswith ( 'win' ) : chunksize = ( _WIN_WRITE_LIMIT // arr . itemsize ) else : return write ( arr , outfile ) idx = 0 arr = arr . view ( np . ndarray ) . flatten ( ) while ( idx < arr . nbytes ) : write ( arr [ idx : ( idx + chunksize ) ] , outfile ) idx += chunksize
write a numpy array to a file or a file-like object .