def write_array(fp, array, version=None):
_check_version(version)<EOL>used_ver = _write_array_header(fp, header_data_from_array_1_0(array),<EOL>version)<EOL>if version != (<NUM_LIT:2>, <NUM_LIT:0>) and used_ver == (<NUM_LIT:2>, <NUM_LIT:0>):<EOL><INDENT>warnings.warn("<STR_LIT>"<EOL>"<STR_LIT>", UserWarning)<EOL><DEDENT>buffersize = max(<NUM_LIT:16> * <NUM_LIT> ** <NUM_LIT:2> // array.itemsize, <NUM_LIT:1>)<EOL>if array.dtype.hasobject:<EOL><INDENT>pickle.dump(array, fp, protocol=<NUM_LIT:2>)<EOL><DEDENT>elif array.flags.f_contiguous and not array.flags.c_contiguous:<EOL><INDENT>if isfileobj(fp):<EOL><INDENT>array.T.tofile(fp)<EOL><DEDENT>else:<EOL><INDENT>for chunk in numpy.nditer(<EOL>array, flags=['<STR_LIT>', '<STR_LIT>', '<STR_LIT>'],<EOL>buffersize=buffersize, order='<STR_LIT:F>'):<EOL><INDENT>fp.write(chunk.tobytes('<STR_LIT:C>'))<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>if isfileobj(fp):<EOL><INDENT>array.tofile(fp)<EOL><DEDENT>else:<EOL><INDENT>for chunk in numpy.nditer(<EOL>array, flags=['<STR_LIT>', '<STR_LIT>', '<STR_LIT>'],<EOL>buffersize=buffersize, order='<STR_LIT:C>'):<EOL><INDENT>fp.write(chunk.tobytes('<STR_LIT:C>'))<EOL><DEDENT><DEDENT><DEDENT>
Write an array to an NPY file, including a header.

If the array is neither C-contiguous nor Fortran-contiguous AND the
file_like object is not a real file object, this function will have to
copy data in memory.

Parameters
----------
fp : file_like object
    An open, writable file object, or similar object with a
    ``.write()`` method.
array : ndarray
    The array to write to disk.
version : (int, int) or None, optional
    The version number of the format. None means use the oldest
    supported version that is able to store the data.  Default: None

Raises
------
ValueError
    If the array cannot be persisted.
Various other errors
    If the array contains Python objects as part of its dtype, the
    process of pickling them may raise various errors if the objects
    are not picklable.