[Numpy-discussion] gradient with memmap array bug (?)

Ralf Gommers ralf.gommers at googlemail.com
Mon Sep 5 12:41:14 EDT 2011


On Mon, Sep 5, 2011 at 12:43 PM, Fred <fredmfp at gmail.com> wrote:

> Hi all,
>
> I get some issue using gradient on an array created from memmap:
>
> PC-Fred[pts/10]:~/{11}/> ipython -p numpy
> Python 2.6.7 (r267:88850, Jul 10 2011, 08:11:54)
> Type "copyright", "credits" or "license" for more information.
>
> IPython 0.10.2 -- An enhanced Interactive Python.
> ?         -> Introduction and overview of IPython's features.
> %quickref -> Quick reference.
> help      -> Python's own help system.
> object?   -> Details about 'object'. ?object also works, ?? prints more.
>
> IPython profile: numpy
>
> PC-Fred[12:39:18]:~/{1}/> a=array([[1.,2.], [3., 4.]], dtype='f')
>
> PC-Fred[12:40:24]:~/{2}/> a.tofile('a.sep')
>
> PC-Fred[12:40:32]:~/{3}/> del a
>
> PC-Fred[12:40:45]:~/{4}/> a = memmap('a.sep', mode='r', dtype='f',
> shape=(2,2))
>
> PC-Fred[12:40:49]:~/{5}/> x, y = gradient(a, 1, 1)
> ---------------------------------------------------------------------------
> AttributeError                            Traceback (most recent call last)
>
> /mnt/common/home/fred/<ipython console> in <module>()
>
> /usr/lib/pymodules/python2.6/numpy/lib/function_base.py in gradient(f,
> *varargs)
>     842     for axis in range(N):
>     843         # select out appropriate parts for this dimension
>
> --> 844         out = np.zeros_like(f).astype(otype)
>     845         slice1[axis] = slice(1, -1)
>     846         slice2[axis] = slice(2, None)
>
> /usr/lib/pymodules/python2.6/numpy/core/memmap.py in
> __array_finalize__(self, obj)
>     255         if hasattr(obj, '_mmap'):
>     256             self._mmap = obj._mmap
> --> 257             self.filename = obj.filename
>     258             self.offset = obj.offset
>     259             self.mode = obj.mode
>
> AttributeError: 'memmap' object has no attribute 'filename'
>
>
> Sounds like a bug or not?
>
> Any clue?
>
> That rings a bell. I can reproduce this with 1.5.1, and it's fixed in
master.

Ralf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110905/f286ca99/attachment.html>


More information about the NumPy-Discussion mailing list