savez(file, *args, **kwds)
Provide arrays as keyword arguments to store them under the corresponding name in the output file: savez(fn, x=x, y=y)
.
If arrays are specified as positional arguments, i.e., savez(fn,
x, y)
, their names will be :None:None:`arr_0`
, :None:None:`arr_1`
, etc.
The .npz
file format is a zipped archive of files named after the variables they contain. The archive is not compressed and each file in the archive contains one variable in .npy
format. For a description of the .npy
format, see numpy.lib.format
.
When opening the saved .npz
file with load
a NpzFile
object is returned. This is a dictionary-like object which can be queried for its list of arrays (with the .files
attribute), and for the arrays themselves.
Keys passed in :None:None:`kwds`
are used as filenames inside the ZIP archive. Therefore, keys should be valid filenames; e.g., avoid keys that begin with /
or contain .
.
When naming variables with keyword arguments, it is not possible to name a variable file
, as this would cause the file
argument to be defined twice in the call to savez
.
Either the filename (string) or an open file (file-like object) where the data will be saved. If file is a string or a Path, the .npz
extension will be appended to the filename if it is not already there.
Arrays to save to the file. Please use keyword arguments (see :None:None:`kwds`
below) to assign names to arrays. Arrays specified as args will be named "arr_0", "arr_1", and so on.
Arrays to save to the file. Each array will be saved to the output file with its corresponding keyword name.
Save several arrays into a single file in uncompressed .npz
format.
save
Save a single array to a binary file in NumPy format.
savetxt
Save an array to a file as plain text.
savez_compressed
Save several arrays into a compressed .npz
archive
>>> from tempfile import TemporaryFile
... outfile = TemporaryFile()
... x = np.arange(10)
... y = np.sin(x)
Using savez
with \*args, the arrays are saved with default names.
>>> np.savez(outfile, x, y)
... _ = outfile.seek(0) # Only needed here to simulate closing & reopening file
... npzfile = np.load(outfile)
... npzfile.files ['arr_0', 'arr_1']
>>> npzfile['arr_0'] array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
Using savez
with \**kwds, the arrays are saved with the keyword names.
>>> outfile = TemporaryFile()
... np.savez(outfile, x=x, y=y)
... _ = outfile.seek(0)
... npzfile = np.load(outfile)
... sorted(npzfile.files) ['x', 'y']
>>> npzfile['x'] array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])See :
The following pages refer to to this document either explicitly or contain code examples using this.
numpy.savez_compressed
numpy.savetxt
numpy.load
scipy.sparse._matrix_io.save_npz
numpy.savez
numpy.save
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them