8000 __setitem__ bug on structured arrays with objects (Trac #1299) · Issue #1897 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
__setitem__ bug on structured arrays with objects (Trac #1299) #1897
Closed
@thouis

Description

@thouis

Original ticket http://projects.scipy.org/numpy/ticket/1299 on 2009-11-19 by trac user crobin, assigned to unknown.

I think there is a bug with __setitem__ when using advanced selection on a structured array with objects when dimension is at least 2.

x = numpy.rec.fromarrays([[0,1],['a','b']], formats='i8,O')[None]
print x
x[x.nonzero()] = x.ravel()[:1]
print x

This gives:

[[(0, 'a') (1, 'b')]]
[[(0, 'a') (0, 'b')]]  ## WRONG

The very last 'b' should be an 'a'.

As a bonus, the reference count of the string ‘b’ decreases, even though it still remains in the array x. So the interpreter will crash if you repeat the above:

while True:
    x[x.nonzero()] = x.ravel()[:1]

...leads to:

Fatal Python error: deletion of interned string failed
zsh: IOT instruction (core dumped)  python2.6

Note that this bug does not seem to occur when x is dimension 1, or when basic selection is used. The offset of the object in the dtype does not seem to matter.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0