{"action":"created","issue":{"url":"https://api.github.com/repos/numpy/numpy/issues/10032","repository_url":"https://api.github.com/repos/numpy/numpy","labels_url":"https://api.github.com/repos/numpy/numpy/issues/10032/labels{/name}","comments_url":"https://api.github.com/repos/numpy/numpy/issues/10032/comments","events_url":"https://api.github.com/repos/numpy/numpy/issues/10032/events","html_url":"https://github.com/numpy/numpy/pull/10032","id":274307698,"number":10032,"title":"MAINT: Remove newline before dtype in repr of arrays ","user":{"login":"ahaldane","id":9040124,"avatar_url":"https://avatars1.githubusercontent.com/u/9040124?v=4","gravatar_id":"","url":"https://api.github.com/users/ahaldane","html_url":"https://github.com/ahaldane","followers_url":"https://api.github.com/users/ahaldane/followers","following_url":"https://api.github.com/users/ahaldane/following{/other_user}","gists_url":"https://api.github.com/users/ahaldane/gists{/gist_id}","starred_url":"https://api.github.com/users/ahaldane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahaldane/subscriptions","organizations_url":"https://api.github.com/users/ahaldane/orgs","repos_url":"https://api.github.com/users/ahaldane/repos","events_url":"https://api.github.com/users/ahaldane/events{/privacy}","received_events_url":"https://api.github.com/users/ahaldane/received_events","type":"User","site_admin":false},"labels":[{"id":6359239,"url":"https://api.github.com/repos/numpy/numpy/labels/01%20-%20Enhancement","name":"01 - Enhancement","color":"fef2c0","default":false},{"id":16917029,"url":"https://api.github.com/repos/numpy/numpy/labels/component:%20numpy.core","name":"component: numpy.core","color":"009800","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/numpy/numpy/milestones/45","html_url":"https://github.com/numpy/numpy/milestone/45","labels_url":"https://api.github.com/repos/numpy/numpy/milestones/45/labels","id":2086704,"number":45,"title":"1.14.0 release","description":"","creator":{"login":"charris","id":77272,"avatar_url":"https://avatars3.githubusercontent.com/u/77272?v=4","gravatar_id":"","url":"https://api.github.com/users/charris","html_url":"https://github.com/charris","followers_url":"https://api.github.com/users/charris/followers","following_url":"https://api.github.com/users/charris/following{/other_user}","gists_url":"https://api.github.com/users/charris/gists{/gist_id}","starred_url":"https://api.github.com/users/charris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/charris/subscriptions","organizations_url":"https://api.github.com/users/charris/orgs","repos_url":"https://api.github.com/users/charris/repos","events_url":"https://api.github.com/users/charris/events{/privacy}","received_events_url":"https://api.github.com/users/charris/received_events","type":"User","site_admin":false},"open_issues":17,"closed_issues":55,"state":"open","created_at":"2016-10-22T19:22:21Z","updated_at":"2017-11-19T17:42:07Z","due_on":null,"closed_at":null},"comments":5,"created_at":"2017-11-15T21:18:17Z","updated_at":"2017-11-20T01:16:45Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/numpy/numpy/pulls/10032","html_url":"https://github.com/numpy/numpy/pull/10032","diff_url":"https://github.com/numpy/numpy/pull/10032.diff","patch_url":"https://github.com/numpy/numpy/pull/10032.patch"},"body":"Fixes #9717 \r\n\r\nThis PR more carefully chooses whether to put a newline before the `dtype=` part of ndarray reprs. If adding the dtype would put the last line of output past the `max_line_width` formatter option, then put the dtype on the new line. Otherwise keep the dtype on the same line. Supports 1.13 legacy mode (must merge #10030 first).\r\n\r\nThe old behavior was to always keep the dtype on the same line for non-flexible-typed arrays (sometimes going past the `max_line_width`), and always put it on a new line for flexible-typed arrays.\r\n\r\nIn the output below I've wrapped the lines as if in an 80-char terminal.\r\n\r\nOld behavior:\r\n```python\r\n>>> np.arange(10,20,dtype='f4')\r\narray([10., 11., 12., 13., 14., 15., 16., 17., 18., 19.], dtype=float32)\r\n>>> np.arange(10,24., dtype='f4')\r\narray([10., 11., 12., 13., 14., 15., 16., 17., 18., 19., 20., 21., 22., 23.], dt\r\nype=float32)\r\n>>> np.ones(3, dtype='S4')\r\narray(['1', '1', '1'],\r\n      dtype='|S4')\r\n>>> np.ones(11, dtype='S4')\r\narray(['1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1'],\r\n      dtype='|S4')\r\n>>> np.ones(12, dtype='S4')\r\narray(['1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1'],\r\n      dtype='|S4')\r\n```\r\n\r\n\r\nNew behavior:\r\n```python\r\n>>> np.arange(10,20., dtype='f4')\r\narray([10., 11., 12., 13., 14., 15., 16., 17., 18., 19.], dtype=float32)\r\n>>> np.arange(10,24., dtype='f4')\r\narray([10., 11., 12., 13., 14., 15., 16., 17., 18., 19., 20., 21., 22., 23.],\r\n      dtype=float32)\r\n>>> np.ones(3, dtype='S4')\r\narray(['1', '1', '1'], dtype='|S4')\r\n>>> np.ones(11, dtype='S4')\r\narray(['1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1'], dtype='|S4')\r\n>>> np.ones(12, dtype='S4')\r\narray(['1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1'],\r\n      dtype='|S4')\r\n```\r\n\r\nRelatedly, I think that a lot of the `linewidth` related code should be rewritten, because there are lots of cases it can go past the user-requested line width. For instance, if you look in `_formatArray` you can see it does not take into account trailing commas, or trailing `]`, so these can go past the `max_line_width`. But I am somewhat loath to try to fix that right now. Note that the default `linewidth` is 75 instead of the standard 80, which I might guess is because of these problems.\r\n\r\nMaybe we can leave those problems alone, and just change the newline for now?"},"comment":{"url":"https://api.github.com/repos/numpy/numpy/issues/comments/345567495","html_url":"https://github.com/numpy/numpy/pull/10032#issuecomment-345567495","issue_url":"https://api.github.com/repos/numpy/numpy/issues/10032","id":345567495,"user":{"login":"ahaldane","id":9040124,"avatar_url":"https://avatars1.githubusercontent.com/u/9040124?v=4","gravatar_id":"","url":"https://api.github.com/users/ahaldane","html_url":"https://github.com/ahaldane","followers_url":"https://api.github.com/users/ahaldane/followers","following_url":"https://api.github.com/users/ahaldane/following{/other_user}","gists_url":"https://api.github.com/users/ahaldane/gists{/gist_id}","starred_url":"https://api.github.com/users/ahaldane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahaldane/subscriptions","organizations_url":"https://api.github.com/users/ahaldane/orgs","repos_url":"https://api.github.com/users/ahaldane/repos","events_url":"https://api.github.com/users/ahaldane/events{/privacy}","received_events_url":"https://api.github.com/users/ahaldane/received_events","type":"User","site_admin":false},"created_at":"2017-11-20T01:16:45Z","updated_at":"2017-11-20T01:16:45Z","author_association":"MEMBER","body":"Updated."}}
{"actor":{"display_login":"ahaldane"}}