{"action":"closed","issue":{"url":"https://api.github.com/repos/numpy/numpy/issues/10277","repository_url":"https://api.github.com/repos/numpy/numpy","labels_url":"https://api.github.com/repos/numpy/numpy/issues/10277/labels{/name}","comments_url":"https://api.github.com/repos/numpy/numpy/issues/10277/comments","events_url":"https://api.github.com/repos/numpy/numpy/issues/10277/events","html_url":"https://github.com/numpy/numpy/issues/10277","id":284515323,"node_id":"MDU6SXNzdWUyODQ1MTUzMjM=","number":10277,"title":"Cannot use inplace assignment when dtype would change","user":{"login":"eric-wieser","id":425260,"node_id":"MDQ6VXNlcjQyNTI2MA==","avatar_url":"https://avatars3.githubusercontent.com/u/425260?v=4","gravatar_id":"","url":"https://api.github.com/users/eric-wieser","html_url":"https://github.com/eric-wieser","followers_url":"https://api.github.com/users/eric-wieser/followers","following_url":"https://api.github.com/users/eric-wieser/following{/other_user}","gists_url":"https://api.github.com/users/eric-wieser/gists{/gist_id}","starred_url":"https://api.github.com/users/eric-wieser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eric-wieser/subscriptions","organizations_url":"https://api.github.com/users/eric-wieser/orgs","repos_url":"https://api.github.com/users/eric-wieser/repos","events_url":"https://api.github.com/users/eric-wieser/events{/privacy}","received_events_url":"https://api.github.com/users/eric-wieser/received_events","type":"User","site_admin":false},"labels":[{"id":6359893,"node_id":"MDU6TGFiZWw2MzU5ODkz","url":"https://api.github.com/repos/numpy/numpy/labels/15%20-%20Discussion","name":"15 - Discussion","color":"fef2c0","default":false},{"id":81818822,"node_id":"MDU6TGFiZWw4MTgxODgyMg==","url":"https://api.github.com/repos/numpy/numpy/labels/57%20-%20Close?","name":"57 - Close?","color":"207de5","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2017-12-26T08:20:03Z","updated_at":"2018-08-14T01:47:49Z","closed_at":"2018-08-14T01:47:49Z","author_association":"MEMBER","body":"For instance, the following fails:\r\n```\r\ndt = np.arange(10).astype('m8[D]')\r\ndt += np.datetime64('now', 'D')\r\n# TypeError: Cannot cast ufunc add output from dtype('<M8[s]') to dtype('<M8[D]') with casting rule 'same_kind'\r\n```\r\nwhile this works as intended:\r\n```\r\ndt = np.arange(10).astype('m8[D]')\r\ndt = dt + np.datetime64('now', 'D')\r\n```\r\n\r\nWe could give the former the semantics of the latter by returning `NotImplemented` from `ndarray.__iadd__` if the dtypes aren't compatible.\r\n\r\nIs making this change desirable?\r\n\r\nArguments for:\r\n* In place assignment can be used as an optimization, without breaking behavior for non-homogenous dtypes\r\n* Consistency with python, where `+=` has semantics that vary by variable type.\r\n\r\nArguments against:\r\n* `+=` no longer has \"always mutates in place\" semantics (that is now spelt `x[...] += y`)"}}
{"actor":{"display_login":"mattip"}}