diff options
Diffstat (limited to 'numpy/lib')
-rw-r--r-- | numpy/lib/npyio.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index cb71ffad5..07a8ca429 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -285,7 +285,8 @@ def load(file, mmap_mode=None): Returns ------- result : array, tuple, dict, etc. - Data stored in the file. + Data stored in the file. For '.npz' files, the returned instance of + NpzFile class must be closed to avoid leaking file descriptors. Raises ------ @@ -315,6 +316,17 @@ def load(file, mmap_mode=None): array([[1, 2, 3], [4, 5, 6]]) + Store compressed data to disk, and load it again: + + >>> np.savez('/tmp/123.npz', a=np.array([[1, 2, 3], [4, 5, 6]]), b=np.array([1, 2])) + >>> data = np.load('/tmp/123.npy') + >>> data['a'] + array([[1, 2, 3], + [4, 5, 6]]) + >>> data['b'] + array([1, 2]) + >>> data.close() + Mem-map the stored array, and then access the second row directly from disk: |