[Numpy-svn] r8326 - trunk/numpy/core

numpy-svn@scip... numpy-svn@scip...
Mon Apr 12 18:11:40 CDT 2010


Author: charris
Date: 2010-04-12 18:11:40 -0500 (Mon, 12 Apr 2010)
New Revision: 8326

Modified:
   trunk/numpy/core/memmap.py
Log:
ENH: Make the new memmap filename attribute store the full path to the file.
Add offset and mode attributes to the memmap class.

Modified: trunk/numpy/core/memmap.py
===================================================================
--- trunk/numpy/core/memmap.py	2010-04-12 20:35:59 UTC (rev 8325)
+++ trunk/numpy/core/memmap.py	2010-04-12 23:11:40 UTC (rev 8326)
@@ -109,6 +109,9 @@
             [  4.,   5.,   6.,   7.],
             [  8.,   9.,  10.,  11.]], dtype=float32)
 
+    >>> fp.filename == path.abspath(filename)
+    True
+
     Deletion flushes memory changes to disk before removing the object:
 
     >>> del fp
@@ -166,6 +169,7 @@
                 shape=None, order='C'):
         # Import here to minimize 'import numpy' overhead
         import mmap
+        import os.path
         try:
             mode = mode_equivalents[mode]
         except KeyError:
@@ -227,13 +231,22 @@
         self = ndarray.__new__(subtype, shape, dtype=descr, buffer=mm,
             offset=offset, order=order)
         self._mmap = mm
-        self.filename = filename
+        self.offset = offset
+        self.mode = mode
+
+        if isinstance(filename, basestring):
+            self.filename = os.path.abspath(filename)
+        elif hasattr(filename, "name"):
+            self.filename = filename.name
+
         return self
 
     def __array_finalize__(self, obj):
         if hasattr(obj, '_mmap'):
             self._mmap = obj._mmap
             self.filename = obj.filename
+            self.offset = obj.offset
+            self.mode = obj.mode
         else:
             self._mmap = None
 



More information about the Numpy-svn mailing list