diff options
author | Stefan van der Walt <stefan@sun.ac.za> | 2008-11-29 12:08:29 +0000 |
---|---|---|
committer | Stefan van der Walt <stefan@sun.ac.za> | 2008-11-29 12:08:29 +0000 |
commit | 05fa6e737f1ed9a0b0b34a9c90a3c386b600e121 (patch) | |
tree | df0e0c9d2a4e1dd5eec521e03b7ed4c99cd19a29 /numpy/lib/format.py | |
parent | 3cc4c43bfd2226f76f35054a99e8f2d2a3ac466a (diff) | |
download | numpy-05fa6e737f1ed9a0b0b34a9c90a3c386b600e121.tar.gz |
Opening a memmap requires a filename. Raise an error otherwise.
Diffstat (limited to 'numpy/lib/format.py')
-rw-r--r-- | numpy/lib/format.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/numpy/lib/format.py b/numpy/lib/format.py index 32a23ae18..28444613c 100644 --- a/numpy/lib/format.py +++ b/numpy/lib/format.py @@ -381,7 +381,7 @@ def read_array(fp): def open_memmap(filename, mode='r+', dtype=None, shape=None, - fortran_order=False, version=(1,0)): + fortran_order=False, version=(1,0)): """ Open a .npy file as a memory-mapped array. @@ -390,7 +390,7 @@ def open_memmap(filename, mode='r+', dtype=None, shape=None, Parameters ---------- filename : str - The name of the file on disk. This may not be a filelike object. + The name of the file on disk. This may not be a file-like object. mode : str, optional The mode to open the file with. In addition to the standard file modes, 'c' is also accepted to mean "copy on write". See `numpy.memmap` for @@ -425,6 +425,10 @@ def open_memmap(filename, mode='r+', dtype=None, shape=None, numpy.memmap """ + if not isinstance(filename, basestring): + raise ValueError("Filename must be a string. Memmap cannot use" \ + " existing file handles.") + if 'w' in mode: # We are creating the file, not reading it. # Check if we ought to create the file. |