Thanks to visit codestin.com
Credit goes to github.com

Skip to content

empty_like not passing across attributes of memmap objects (Trac #1753) #2348

@numpy-gitbot

Description

@numpy-gitbot

Original ticket http://projects.scipy.org/numpy/ticket/1753 on 2011-03-03 by trac user bryancole, assigned to unknown.

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions