Skip to content

Surprising results from in-place operations involving views (Trac #1085) #1683

@thouis

Description

@thouis

Original ticket http://projects.scipy.org/numpy/ticket/1085 on 2009-04-15 by trac user tillmann, assigned to @charris.

import numpy as np
x=np.array([[1,2],[3,4]])
print x
[[1 2]
[3 4]]
x+=x.T
print x
[[2 5]
[8 8]]

when writing code on such a high level of abstraction this behavior is not expected and imho wrong. At least a warning should be issued or better the in place operations should fall back to creating copies if the results are not correct otherwise.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions