class NpzFile(Mapping):
NpzFile(fid)
A dictionary-like object with lazy-loading of files in the zipped archive provided on construction.
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.
NpzFile
instance itself.Allow loading pickled data. Default: False
fid
is a file-like object.>>> from tempfile import TemporaryFile >>> outfile = TemporaryFile() >>> x = np.arange(10) >>> y = np.sin(x) >>> np.savez(outfile, x=x, y=y) >>> _ = outfile.seek(0)
>>> 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])
Method | __del__ |
Undocumented |
Method | __enter__ |
Undocumented |
Method | __exit__ |
Undocumented |
Method | __getitem__ |
Undocumented |
Method | __init__ |
Undocumented |
Method | __iter__ |
Undocumented |
Method | __len__ |
Undocumented |
Method | close |
Close the file. |
Method | iteritems |
Undocumented |
Method | iterkeys |
Undocumented |
Instance Variable | _files |
Undocumented |
Instance Variable | allow_pickle |
Undocumented |
Instance Variable | f |
Undocumented |
Instance Variable | fid |
Undocumented |
Instance Variable | files |
Undocumented |
Instance Variable | pickle_kwargs |
Undocumented |
Instance Variable | zip |
Undocumented |