diff options
Diffstat (limited to 'numpy/core/memmap.py')
-rw-r--r-- | numpy/core/memmap.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/numpy/core/memmap.py b/numpy/core/memmap.py index fe52b3a09..f068c7b6c 100644 --- a/numpy/core/memmap.py +++ b/numpy/core/memmap.py @@ -4,7 +4,7 @@ import warnings from numeric import uint8, ndarray, dtype import sys -from numpy.compat import asbytes +import numpy as np dtypedescr = dtype valid_filemodes = ["r", "c", "r+", "w+"] @@ -235,7 +235,7 @@ class memmap(ndarray): if mode == 'w+' or (mode == 'r+' and flen < bytes): fid.seek(bytes - 1, 0) - fid.write(asbytes('\0')) + fid.write(np.compat.asbytes('\0')) fid.flush() if mode == 'c': @@ -271,13 +271,16 @@ class memmap(ndarray): return self def __array_finalize__(self, obj): - if hasattr(obj, '_mmap'): + if hasattr(obj, '_mmap') and np.may_share_memory(self, obj): self._mmap = obj._mmap self.filename = obj.filename self.offset = obj.offset self.mode = obj.mode else: self._mmap = None + self.filename = None + self.offset = None + self.mode = None def flush(self): """ |