summaryrefslogtreecommitdiff
path: root/numpy/lib/npyio.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2014-03-01 07:04:07 -0700
committerCharles Harris <charlesr.harris@gmail.com>2014-03-01 07:04:07 -0700
commita4e76451a7c93e2ba521a2205a762b26ed7c4616 (patch)
tree883bc0eebc7f9eaeaeb0a79214bef5b4ca77bcc8 /numpy/lib/npyio.py
parent50da92a6980cd88a39c587c257fe35dc0c470f5a (diff)
parent73750e64c62412f26f5188a92f3ea194e0b29600 (diff)
downloadnumpy-a4e76451a7c93e2ba521a2205a762b26ed7c4616.tar.gz
Merge pull request #4376 from charris/fix-gh-2807
DOC: Improve the documentation of numpy.load.
Diffstat (limited to 'numpy/lib/npyio.py')
-rw-r--r--numpy/lib/npyio.py32
1 files changed, 18 insertions, 14 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py
index 8cd779f4d..2310b9be2 100644
--- a/numpy/lib/npyio.py
+++ b/numpy/lib/npyio.py
@@ -285,21 +285,23 @@ def load(file, mmap_mode=None):
Parameters
----------
file : file-like object or string
- The file to read. It must support ``seek()`` and ``read()`` methods.
- If the filename extension is ``.gz``, the file is first decompressed.
+ The file to read. Compressed files with the filename extension
+ ``.gz`` are acceptable. File-like objects must support the
+ ``seek()`` and ``read()`` methods. Pickled files require that the
+ file-like object support the ``readline()`` method as well.
mmap_mode : {None, 'r+', 'r', 'w+', 'c'}, optional
- If not None, then memory-map the file, using the given mode
- (see `numpy.memmap` for a detailed description of the modes).
- A memory-mapped array is kept on disk. However, it can be accessed
- and sliced like any ndarray. Memory mapping is especially useful for
- accessing small fragments of large files without reading the entire
- file into memory.
+ If not None, then memory-map the file, using the given mode (see
+ `numpy.memmap` for a detailed description of the modes). A
+ memory-mapped array is kept on disk. However, it can be accessed
+ and sliced like any ndarray. Memory mapping is especially useful
+ for accessing small fragments of large files without reading the
+ entire file into memory.
Returns
-------
result : array, tuple, dict, etc.
- Data stored in the file. For ``.npz`` files, the returned instance of
- NpzFile class must be closed to avoid leaking file descriptors.
+ Data stored in the file. For ``.npz`` files, the returned instance
+ of NpzFile class must be closed to avoid leaking file descriptors.
Raises
------
@@ -308,7 +310,7 @@ def load(file, mmap_mode=None):
See Also
--------
- save, savez, loadtxt
+ save, savez, savez_compressed, loadtxt
memmap : Create a memory-map to an array stored in a file on disk.
Notes
@@ -319,13 +321,14 @@ def load(file, mmap_mode=None):
- If the file is a ``.npz`` file, then a dictionary-like object is
returned, containing ``{filename: array}`` key-value pairs, one for
each file in the archive.
- - If the file is a ``.npz`` file, the returned value supports the context
- manager protocol in a similar fashion to the open function::
+ - If the file is a ``.npz`` file, the returned value supports the
+ context manager protocol in a similar fashion to the open function::
with load('foo.npz') as data:
a = data['a']
- The underlying file descriptor is closed when exiting the 'with' block.
+ The underlying file descriptor is closed when exiting the 'with'
+ block.
Examples
--------
@@ -549,6 +552,7 @@ def savez_compressed(file, *args, **kwds):
See Also
--------
numpy.savez : Save several arrays into an uncompressed ``.npz`` file format
+ numpy.load : Load the files created by savez_compressed.
"""
_savez(file, args, kwds, True)