[Numpy-svn] r6121 - trunk/numpy/lib

numpy-svn@scip... numpy-svn@scip...
Sat Nov 29 06:08:42 CST 2008


Author: stefan
Date: 2008-11-29 06:08:29 -0600 (Sat, 29 Nov 2008)
New Revision: 6121

Modified:
   trunk/numpy/lib/format.py
Log:
Opening a memmap requires a filename.  Raise an error otherwise.

Modified: trunk/numpy/lib/format.py
===================================================================
--- trunk/numpy/lib/format.py	2008-11-29 12:07:54 UTC (rev 6120)
+++ trunk/numpy/lib/format.py	2008-11-29 12:08:29 UTC (rev 6121)
@@ -381,7 +381,7 @@
 
 
 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 @@
     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 @@
     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.



More information about the Numpy-svn mailing list