{"action":"created","issue":{"url":"https://api.github.com/repos/numpy/numpy/issues/5241","labels_url":"https://api.github.com/repos/numpy/numpy/issues/5241/labels{/name}","comments_url":"https://api.github.com/repos/numpy/numpy/issues/5241/comments","events_url":"https://api.github.com/repos/numpy/numpy/issues/5241/events","html_url":"https://github.com/numpy/numpy/issues/5241","id":46973412,"number":5241,"title":"Bug: Adding a transposed array to itself","user":{"login":"petered","id":1148799,"avatar_url":"https://avatars.githubusercontent.com/u/1148799?v=3","gravatar_id":"","url":"https://api.github.com/users/petered","html_url":"https://github.com/petered","followers_url":"https://api.github.com/users/petered/followers","following_url":"https://api.github.com/users/petered/following{/other_user}","gists_url":"https://api.github.com/users/petered/gists{/gist_id}","starred_url":"https://api.github.com/users/petered/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petered/subscriptions","organizations_url":"https://api.github.com/users/petered/orgs","repos_url":"https://api.github.com/users/petered/repos","events_url":"https://api.github.com/users/petered/events{/privacy}","received_events_url":"https://api.github.com/users/petered/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2014-10-27T23:38:08Z","updated_at":"2015-06-19T21:07:58Z","closed_at":null,"body":"Something very strange happens when you try adding a transposed array to itself:\r\n```\r\n>>> import numpy as np\r\n>>> arr = np.ones((100, 100))\r\n>>> arr+=arr.T\r\n>>> arr\r\narray([[ 2.,  2.,  2., ...,  2.,  2.,  2.],\r\n       [ 2.,  2.,  2., ...,  2.,  2.,  2.],\r\n       [ 2.,  2.,  2., ...,  2.,  2.,  2.],\r\n       ..., \r\n       [ 3.,  3.,  3., ...,  2.,  2.,  2.],\r\n       [ 3.,  3.,  3., ...,  2.,  2.,  2.],\r\n       [ 3.,  3.,  3., ...,  2.,  2.,  2.]])\r\n>>> np.sum(arr==2)\r\n8532\r\n>>> np.sum(arr==3)\r\n1468\r\n```\r\n`arr = arr + arr.T` works fine of course.\r\n\r\nIt looks like because arr.T is a view of arr, while reading values out of arr.T it reads elements of arr that have already been written to.  This could lead to some really sneaky bugs. Even just detecting the situation and raising an exception would be an acceptable solution.  \r\n\r\n"},"comment":{"url":"https://api.github.com/repos/numpy/numpy/issues/comments/113645648","html_url":"https://github.com/numpy/numpy/issues/5241#issuecomment-113645648","issue_url":"https://api.github.com/repos/numpy/numpy/issues/5241","id":113645648,"user":{"login":"argriffing","id":101416,"avatar_url":"https://avatars.githubusercontent.com/u/101416?v=3","gravatar_id":"","url":"https://api.github.com/users/argriffing","html_url":"https://github.com/argriffing","followers_url":"https://api.github.com/users/argriffing/followers","following_url":"https://api.github.com/users/argriffing/following{/other_user}","gists_url":"https://api.github.com/users/argriffing/gists{/gist_id}","starred_url":"https://api.github.com/users/argriffing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/argriffing/subscriptions","organizations_url":"https://api.github.com/users/argriffing/orgs","repos_url":"https://api.github.com/users/argriffing/repos","events_url":"https://api.github.com/users/argriffing/events{/privacy}","received_events_url":"https://api.github.com/users/argriffing/received_events","type":"User","site_admin":false},"created_at":"2015-06-19T21:07:58Z","updated_at":"2015-06-19T21:07:58Z","body":"Should this issue be closed as 'not a bug' or 'wont fix' or something to that effect?"}}