diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2010-04-12 23:11:40 +0000 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2010-04-12 23:11:40 +0000 |
commit | 77f4e079f3a35984787e6e60e2303f79bd4ec33a (patch) | |
tree | a85d160a1a1e65ca0fdf9d60fe7eda356d38fcc6 /numpy/core/memmap.py | |
parent | 4d821188c3baeefccaff0d8074ea0ee838327f66 (diff) | |
download | numpy-77f4e079f3a35984787e6e60e2303f79bd4ec33a.tar.gz |
ENH: Make the new memmap filename attribute store the full path to the file.
Add offset and mode attributes to the memmap class.
Diffstat (limited to 'numpy/core/memmap.py')
-rw-r--r-- | numpy/core/memmap.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/numpy/core/memmap.py b/numpy/core/memmap.py index b4a25cf9c..de27553d8 100644 --- a/numpy/core/memmap.py +++ b/numpy/core/memmap.py @@ -109,6 +109,9 @@ class memmap(ndarray): [ 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 @@ class memmap(ndarray): 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 @@ class memmap(ndarray): 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 |