{"action":"created","issue":{"url":"https://api.github.com/repos/numpy/numpy/issues/5611","labels_url":"https://api.github.com/repos/numpy/numpy/issues/5611/labels{/name}","comments_url":"https://api.github.com/repos/numpy/numpy/issues/5611/comments","events_url":"https://api.github.com/repos/numpy/numpy/issues/5611/events","html_url":"https://github.com/numpy/numpy/issues/5611","id":59137502,"number":5611,"title":"Unexpected result when feeding empty array into atleast_2d","user":{"login":"mtrbean","id":222778,"avatar_url":"https://avatars.githubusercontent.com/u/222778?v=3","gravatar_id":"","url":"https://api.github.com/users/mtrbean","html_url":"https://github.com/mtrbean","followers_url":"https://api.github.com/users/mtrbean/followers","following_url":"https://api.github.com/users/mtrbean/following{/other_user}","gists_url":"https://api.github.com/users/mtrbean/gists{/gist_id}","starred_url":"https://api.github.com/users/mtrbean/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtrbean/subscriptions","organizations_url":"https://api.github.com/users/mtrbean/orgs","repos_url":"https://api.github.com/users/mtrbean/repos","events_url":"https://api.github.com/users/mtrbean/events{/privacy}","received_events_url":"https://api.github.com/users/mtrbean/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-02-26T20:25:05Z","updated_at":"2015-02-26T22:52:19Z","closed_at":null,"body":"I was expecting a square array `array([], shape=(0, 0), dtype=float64)`, but got `shape=(1,0)`. Is this the intended behavior?\r\n\r\n    In [14]: np.empty(0).shape\r\n    Out[14]: (0,)\r\n\r\n    In [15]: np.atleast_2d(np.empty(0))\r\n    Out[15]: array([], shape=(1, 0), dtype=float64)\r\n\r\nThe reason is that I needed a 2D array from `hsplit` and `vhsplit`, but the dimension is not preserved when the result happens to be empty (gh-4102). I tried to work around the issue with `atleast_2d`, and found that it doesn't work because `atleast_2d` doesn't give me a square array with shape `(0,0)`"},"comment":{"url":"https://api.github.com/repos/numpy/numpy/issues/comments/76292772","html_url":"https://github.com/numpy/numpy/issues/5611#issuecomment-76292772","issue_url":"https://api.github.com/repos/numpy/numpy/issues/5611","id":76292772,"user":{"login":"jaimefrio","id":3343990,"avatar_url":"https://avatars.githubusercontent.com/u/3343990?v=3","gravatar_id":"","url":"https://api.github.com/users/jaimefrio","html_url":"https://github.com/jaimefrio","followers_url":"https://api.github.com/users/jaimefrio/followers","following_url":"https://api.github.com/users/jaimefrio/following{/other_user}","gists_url":"https://api.github.com/users/jaimefrio/gists{/gist_id}","starred_url":"https://api.github.com/users/jaimefrio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaimefrio/subscriptions","organizations_url":"https://api.github.com/users/jaimefrio/orgs","repos_url":"https://api.github.com/users/jaimefrio/repos","events_url":"https://api.github.com/users/jaimefrio/events{/privacy}","received_events_url":"https://api.github.com/users/jaimefrio/received_events","type":"User","site_admin":false},"created_at":"2015-02-26T22:52:19Z","updated_at":"2015-02-26T22:52:19Z","body":"If you want an array of shape `(0, 0)` you can always set it explicitly yourself:\r\n\r\n```\r\n>>> a = np.array([])\r\n>>> a.shape\r\n(0,)\r\n>>> a.shape = (0, 0)\r\n>>> a.shape\r\n(0, 0)\r\n```\r\n\r\nActually, as long as the total array size is unchanged, i.e. there is a zero somewhere in the shape, you can do whatever you want with the shape:\r\n\r\n```\r\n>>> a.shape = (237, 0, 457)\r\n>>> a.shape\r\n(237, 0, 457)\r\n```\r\n\r\nThe behavior of `atleast_xd` and `newaxis` is one that works with any array, including empty ones. Why does it even make a difference to you if the empty array is square or not? Does it even make sense to worry about the shape of an empty array? What generic benefit do you see in changing the behavior of `atleast_xd` to support your particular choice of behavior?"}}