Skip to content

Broken __iadd__ behavior on views #6119

@akhmerov

Description

@akhmerov

Using += with a view of the same array sometimes is broken. To reproduce run

for n in range(80, 100):
    h = np.random.randn(n, n)
    h += h.T
    print(n, np.linalg.norm(h - h.T))

This produces a bunch of zeros (correct result), followed by a bunch of finite numbers of order 1 (wrong). For me the result is wrong for n > 90.

Replacing h += h.T with h = h + h.T or anything equivalent fixes the issue.

I have verified that the issue appears in linux pip installation of numpy v1.9.2 in python 2, as well as python 3. In particular, it is reproducible on http://try.jupyter.org.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions