{"action":"created","issue":{"url":"https://api.github.com/repos/numpy/numpy/issues/8733","repository_url":"https://api.github.com/repos/numpy/numpy","labels_url":"https://api.github.com/repos/numpy/numpy/issues/8733/labels{/name}","comments_url":"https://api.github.com/repos/numpy/numpy/issues/8733/comments","events_url":"https://api.github.com/repos/numpy/numpy/issues/8733/events","html_url":"https://github.com/numpy/numpy/issues/8733","id":211539719,"number":8733,"title":"Unexpected truncation when storing float to int array","user":{"login":"OliverEvans96","id":15915043,"avatar_url":"https://avatars1.githubusercontent.com/u/15915043?v=3","gravatar_id":"","url":"https://api.github.com/users/OliverEvans96","html_url":"https://github.com/OliverEvans96","followers_url":"https://api.github.com/users/OliverEvans96/followers","following_url":"https://api.github.com/users/OliverEvans96/following{/other_user}","gists_url":"https://api.github.com/users/OliverEvans96/gists{/gist_id}","starred_url":"https://api.github.com/users/OliverEvans96/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OliverEvans96/subscriptions","organizations_url":"https://api.github.com/users/OliverEvans96/orgs","repos_url":"https://api.github.com/users/OliverEvans96/repos","events_url":"https://api.github.com/users/OliverEvans96/events{/privacy}","received_events_url":"https://api.github.com/users/OliverEvans96/received_events","type":"User","site_admin":false},"labels":[{"id":6359893,"url":"https://api.github.com/repos/numpy/numpy/labels/02%20-%20Discussion","name":"02 - Discussion","color":"fef2c0","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2017-03-02T22:35:35Z","updated_at":"2017-03-03T02:41:28Z","closed_at":null,"body":"I was caught offguard by the following behavior using numpy 1.12:\r\n\r\n### Current behavior\r\n```\r\nIn  [1]:  a=array([1,0])\r\n          a[0] = 1 + 1.1  \r\n          print(a.dtype)       \r\n          print(a)\r\n          print(a.dtype)               \r\nOut [1]:  int64\r\n          [ 2  0 ]\r\n          int64 \r\n```\r\n\r\n### Expected behavior\r\n```\r\nIn  [2]:  a=array([1,0])\r\n          a[0] = 1 + 1.1  \r\n          print(a.dtype)       \r\n          print(a)\r\n          print(a.dtype)               \r\nOut [2]:  int64\r\n          [ 2.1  0. ]\r\n          float64\r\n```\r\n\r\nIt may be that this is intentional behavior, but I would like to suggest automatic conversion of integer arrays to floating point arrays when a float is saved to an element or slice of the array. I'm not sure how straighforward implementation of this feature would be.\r\n\r\nAt the very least, there ought to be a warning when truncation occurs, especially since I at no point in the above code explicity declare the dtype of A to be int64, so I (and I think most users) would expect it to default to float64.\r\n\r\nI'm interested in opinions on the matter.\r\n\r\nThanks,\r\nOliver"},"comment":{"url":"https://api.github.com/repos/numpy/numpy/issues/comments/283849213","html_url":"https://github.com/numpy/numpy/issues/8733#issuecomment-283849213","issue_url":"https://api.github.com/repos/numpy/numpy/issues/8733","id":283849213,"user":{"login":"eric-wieser","id":425260,"avatar_url":"https://avatars0.githubusercontent.com/u/425260?v=3","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},"created_at":"2017-03-03T02:41:28Z","updated_at":"2017-03-03T02:41:28Z","body":"`array_assign_subscript` is most like the place to look."}}
{"actor":{"display_login":"eric-wieser"}}