numpy 1.22.4 Pypi GitHub Homepage
Other Docs
AttributesParametersBackRef
NpzFile(fid)

Attributes

files : list of str

List of all files in the archive with a .npy extension.

zip : ZipFile instance

The ZipFile object initialized with the zipped archive.

f : BagObj instance

An object on which attribute can be performed as an alternative to getitem access on the NpzFile instance itself.

allow_pickle : bool, optional

Allow loading pickled data. Default: False

versionchanged

Made default False in response to CVE-2019-6446.

pickle_kwargs : dict, optional

Additional keyword arguments to pass on to pickle.load. These are only useful when loading object arrays saved on Python 2 when using Python 3.

NpzFile is used to load files in the NumPy .npz data archive format. It assumes that files in the archive have a .npy extension, other files are ignored.

The arrays and file strings are lazily loaded on either getitem access using obj['key'] or attribute lookup using obj.f.key . A list of all files (without .npy extensions) can be obtained with obj.files and the ZipFile object itself using obj.zip .

Parameters

fid : file or str

The zipped archive to open. This is either a file-like object or a string containing the path to the archive.

own_fid : bool, optional

Whether NpzFile should close the file handle. Requires that :None:None:`fid` is a file-like object.

A dictionary-like object with lazy-loading of files in the zipped archive provided on construction.

Examples

>>> from tempfile import TemporaryFile
... outfile = TemporaryFile()
... x = np.arange(10)
... y = np.sin(x)
... np.savez(outfile, x=x, y=y)
... _ = outfile.seek(0)
This example is valid syntax, but raise an exception at execution
>>> npz = np.load(outfile)
... isinstance(npz, np.lib.io.NpzFile) True
>>> sorted(npz.files)
['x', 'y']
>>> npz['x']  # getitem access
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> npz.f.x  # attribute lookup
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

numpy.lib.npyio.NpzFile numpy.savez numpy.savez_compressed

Local connectivity graph

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


GitHub : /numpy/lib/npyio.py#104
type: <class 'abc.ABCMeta'>
Commit: