You are viewing an older version (2.4.3). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.4.3 / numpy / lib / format / write_array

function

numpy.lib.format:write_array

source: /numpy/lib/_format_impl.py :702

Signature

def   write_array ( fp array version = None allow_pickle = True pickle_kwargs = None )

Summary

Write an array to an NPY file, including a header.

Extended Summary

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

allow_pickle : bool, optional

Whether to allow writing pickled data. Default: True

pickle_kwargs : dict, optional

Additional keyword arguments to pass to pickle.dump, excluding 'protocol'. These are only useful when pickling objects in object arrays to Python 2 compatible format.

Raises

: ValueError

If the array cannot be persisted. This includes the case of allow_pickle=False and array being an object array.

: 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.

Aliases

  • numpy.lib._format_impl.write_array