[NumPy-Tickets] [NumPy] #1753: empty_like not passing across attributes of memmap objects
NumPy Trac
numpy-tickets@scipy....
Thu Mar 3 10:21:09 CST 2011
#1753: empty_like not passing across attributes of memmap objects
------------------------+---------------------------------------------------
Reporter: bryancole | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 2.0.0
Component: numpy.core | Version: 1.5.1
Keywords: memmap |
------------------------+---------------------------------------------------
If I create a memmap object:
{{{
>>> a = numpy.memmap("foo", mode="w+", shape=10)
}}}
then later I create a new array thus:
{{{
>>> b = numpy.empty_like(a)
}}}
then b is also a memmap object. However, even though the type of b is
'memmap', it has no _mmap attribute (as you'd expect, since empty_like
cannot know what file object to use).
The broken memmap object b causes failures elsewhere in __array_finalise__
as it tries to copy attributes from b (filename, offset, mode) which do
not exist.
In summary there are TWO bugs here:
1) empty_like (and friends) should not return objects of type memmap
2) the memmap.__array_finalise__ method is checking for the existence of
the _mmap attribute. In non-memmap objects, this may exist but be set to
None, therefore this method needs to check that both _mmap exists as an
attribute and is not None.
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1753>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list