{"action":"created","comment":{"url":"https://api.github.com/repos/numpy/numpy/pulls/comments/54326237","id":54326237,"diff_hunk":"@@ -32,6 +32,75 @@ def _min_int(low, high):\n     return int64\n \n \n+def flip(m, axis):\n+    \"\"\"\n+    Reverse the order of elements in an array along the given axis.\n+\n+    The shape of the array is preserved, but the elements are reordered.\n+\n+    Parameters\n+    ----------\n+    m : array_like\n+        Input array.\n+    axis: integer\n+        Axis in array, which entries are reversed.\n+        \n+\n+    Returns\n+    -------\n+    out : array_like\n+        A view of `m` with the entries of axis reversed.  Since a view is\n+        returned, this operation is :math:`\\\\mathcal O(1)`.\n+\n+    See Also\n+    --------\n+    flipud : Flip an array vertically (axis=0).\n+    fliplr : Flip an array horizontally (axis=1).\n+\n+    Notes\n+    -----\n+    flip(m, 0) is equivalent to flipud(m).\n+    flip(m, 1) is equivalent to fliplr(m).\n+    flip(m, n) corresponds to ``A[...,::-1,...]`` with ``::-1`` at position n.\n+\n+    Examples\n+    --------\n+    >>> A = np.arange(8).reshape((2,2,2))\n+    >>> A\n+    array([[[0, 1],\n+            [2, 3]],\n+\n+           [[4, 5],\n+            [6, 7]]])\n+\n+    >>> flip(A, 0)\n+    array([[[4, 5],\n+            [6, 7]],\n+    \n+           [[0, 1],\n+            [2, 3]]])\n+\n+    >>> flip(A, 1)\n+    array([[[2, 3],\n+            [0, 1]],\n+    \n+           [[6, 7],\n+            [4, 5]]])\n+\n+    >>> A = np.random.randn(3,4,5)\n+    >>> np.all(flip(A,2)==A[:,:,::-1,...])\n+    True\n+    \"\"\"\n+    if not hasattr(m, 'ndim'):\n+        m = asarray(m)\n+    if m.ndim <= axis:","path":"numpy/lib/twodim_base.py","position":74,"original_position":74,"commit_id":"dbcb2db706ebcd7bb6faf0c0fe207ca623ac61fc","original_commit_id":"dbcb2db706ebcd7bb6faf0c0fe207ca623ac61fc","user":{"login":"mhvk","id":2789820,"avatar_url":"https://avatars.githubusercontent.com/u/2789820?v=3","gravatar_id":"","url":"https://api.github.com/users/mhvk","html_url":"https://github.com/mhvk","followers_url":"https://api.github.com/users/mhvk/followers","following_url":"https://api.github.com/users/mhvk/following{/other_user}","gists_url":"https://api.github.com/users/mhvk/gists{/gist_id}","starred_url":"https://api.github.com/users/mhvk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhvk/subscriptions","organizations_url":"https://api.github.com/users/mhvk/orgs","repos_url":"https://api.github.com/users/mhvk/repos","events_url":"https://api.github.com/users/mhvk/events{/privacy}","received_events_url":"https://api.github.com/users/mhvk/received_events","type":"User","site_admin":false},"body":"This doesn't cover negative values of `axis`. I would remove this altogether and replace it by making the assignment part of a try/except, as follows:\r\n```\r\n    try:\r\n        indexer[axis] = slice(None, None, -1)\r\n    except IndexError:\r\n        raise ValueError(...)\r\n```\r\nQuestion: Should this be an `IndexError` rather than a `ValueError`?\r\n\r\n","created_at":"2016-02-27T02:30:38Z","updated_at":"2016-02-27T02:30:38Z","html_url":"https://github.com/numpy/numpy/pull/7346#discussion_r54326237","pull_request_url":"https://api.github.com/repos/numpy/numpy/pulls/7346","_links":{"self":{"href":"https://api.github.com/repos/numpy/numpy/pulls/comments/54326237"},"html":{"href":"https://github.com/numpy/numpy/pull/7346#discussion_r54326237"},"pull_request":{"href":"https://api.github.com/repos/numpy/numpy/pulls/7346"}}},"pull_request":{"url":"https://api.github.com/repos/numpy/numpy/pulls/7346","id":60864573,"html_url":"https://github.com/numpy/numpy/pull/7346","diff_url":"https://github.com/numpy/numpy/pull/7346.diff","patch_url":"https://github.com/numpy/numpy/pull/7346.patch","issue_url":"https://api.github.com/repos/numpy/numpy/issues/7346","number":7346,"state":"open","locked":false,"title":"Generalized flip","user":{"login":"erensezener","id":759897,"avatar_url":"https://avatars.githubusercontent.com/u/759897?v=3","gravatar_id":"","url":"https://api.github.com/users/erensezener","html_url":"https://github.com/erensezener","followers_url":"https://api.github.com/users/erensezener/followers","following_url":"https://api.github.com/users/erensezener/following{/other_user}","gists_url":"https://api.github.com/users/erensezener/gists{/gist_id}","starred_url":"https://api.github.com/users/erensezener/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erensezener/subscriptions","organizations_url":"https://api.github.com/users/erensezener/orgs","repos_url":"https://api.github.com/users/erensezener/repos","events_url":"https://api.github.com/users/erensezener/events{/privacy}","received_events_url":"https://api.github.com/users/erensezener/received_events","type":"User","site_admin":false},"body":"This PR generalizes ```fliplr``` and ```flipud``` for arbitrary axes. \r\n\r\n```flipud```  and ```fliplr``` reverse the elements of an array along ```axis=0``` and ```axis=1``` respectively. The ```flip``` function reverses the elements of an array along any given axis. In case ```flip``` is called with  ```axis=0``` or  ```axis=1```, the function is equivalent to ```flipud```  and ```fliplr``` respectively.\r\n\r\nA similar function is also available in MATLAB™.\r\n\r\nThis pull request is part of a BCCN Berlin student project by @denisalevi @ge00rg @erensezener","created_at":"2016-02-26T16:14:10Z","updated_at":"2016-02-27T02:30:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bbea7e3813a902480ea8d3ef4a0b4d4d7f4860a4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/numpy/numpy/pulls/7346/commits","review_comments_url":"https://api.github.com/repos/numpy/numpy/pulls/7346/comments","review_comment_url":"https://api.github.com/repos/numpy/numpy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/numpy/numpy/issues/7346/comments","statuses_url":"https://api.github.com/repos/numpy/numpy/statuses/dbcb2db706ebcd7bb6faf0c0fe207ca623ac61fc","head":{"label":"erensezener:generalized_flip","ref":"generalized_flip","sha":"dbcb2db706ebcd7bb6faf0c0fe207ca623ac61fc","user":{"login":"erensezener","id":759897,"avatar_url":"https://avatars.githubusercontent.com/u/759897?v=3","gravatar_id":"","url":"https://api.github.com/users/erensezener","html_url":"https://github.com/erensezener","followers_url":"https://api.github.com/users/erensezener/followers","following_url":"https://api.github.com/users/erensezener/following{/other_user}","gists_url":"https://api.github.com/users/erensezener/gists{/gist_id}","starred_url":"https://api.github.com/users/erensezener/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erensezener/subscriptions","organizations_url":"https://api.github.com/users/erensezener/orgs","repos_url":"https://api.github.com/users/erensezener/repos","events_url":"https://api.github.com/users/erensezener/events{/privacy}","received_events_url":"https://api.github.com/users/erensezener/received_events","type":"User","site_admin":false},"repo":{"id":52526484,"name":"numpy","full_name":"erensezener/numpy","owner":{"login":"erensezener","id":759897,"avatar_url":"https://avatars.githubusercontent.com/u/759897?v=3","gravatar_id":"","url":"https://api.github.com/users/erensezener","html_url":"https://github.com/erensezener","followers_url":"https://api.github.com/users/erensezener/followers","following_url":"https://api.github.com/users/erensezener/following{/other_user}","gists_url":"https://api.github.com/users/erensezener/gists{/gist_id}","starred_url":"https://api.github.com/users/erensezener/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erensezener/subscriptions","organizations_url":"https://api.github.com/users/erensezener/orgs","repos_url":"https://api.github.com/users/erensezener/repos","events_url":"https://api.github.com/users/erensezener/events{/privacy}","received_events_url":"https://api.github.com/users/erensezener/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/erensezener/numpy","description":"Numpy main repository","fork":true,"url":"https://api.github.com/repos/erensezener/numpy","forks_url":"https://api.github.com/repos/erensezener/numpy/forks","keys_url":"https://api.github.com/repos/erensezener/numpy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/erensezener/numpy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/erensezener/numpy/teams","hooks_url":"https://api.github.com/repos/erensezener/numpy/hooks","issue_events_url":"https://api.github.com/repos/erensezener/numpy/issues/events{/number}","events_url":"https://api.github.com/repos/erensezener/numpy/events","assignees_url":"https://api.github.com/repos/erensezener/numpy/assignees{/user}","branches_url":"https://api.github.com/repos/erensezener/numpy/branches{/branch}","tags_url":"https://api.github.com/repos/erensezener/numpy/tags","blobs_url":"https://api.github.com/repos/erensezener/numpy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/erensezener/numpy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/erensezener/numpy/git/refs{/sha}","trees_url":"https://api.github.com/repos/erensezener/numpy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/erensezener/numpy/statuses/{sha}","languages_url":"https://api.github.com/repos/erensezener/numpy/languages","stargazers_url":"https://api.github.com/repos/erensezener/numpy/stargazers","contributors_url":"https://api.github.com/repos/erensezener/numpy/contributors","subscribers_url":"https://api.github.com/repos/erensezener/numpy/subscribers","subscription_url":"https://api.github.com/repos/erensezener/numpy/subscription","commits_url":"https://api.github.com/repos/erensezener/numpy/commits{/sha}","git_commits_url":"https://api.github.com/repos/erensezener/numpy/git/commits{/sha}","comments_url":"https://api.github.com/repos/erensezener/numpy/comments{/number}","issue_comment_url":"https://api.github.com/repos/erensezener/numpy/issues/comments{/number}","contents_url":"https://api.github.com/repos/erensezener/numpy/contents/{+path}","compare_url":"https://api.github.com/repos/erensezener/numpy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/erensezener/numpy/merges","archive_url":"https://api.github.com/repos/erensezener/numpy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/erensezener/numpy/downloads","issues_url":"https://api.github.com/repos/erensezener/numpy/issues{/number}","pulls_url":"https://api.github.com/repos/erensezener/numpy/pulls{/number}","milestones_url":"https://api.github.com/repos/erensezener/numpy/milestones{/number}","notifications_url":"https://api.github.com/repos/erensezener/numpy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/erensezener/numpy/labels{/name}","releases_url":"https://api.github.com/repos/erensezener/numpy/releases{/id}","deployments_url":"https://api.github.com/repos/erensezener/numpy/deployments","created_at":"2016-02-25T13:32:51Z","updated_at":"2016-02-25T13:32:57Z","pushed_at":"2016-02-27T00:53:47Z","git_url":"git://github.com/erensezener/numpy.git","ssh_url":"git@github.com:erensezener/numpy.git","clone_url":"https://github.com/erensezener/numpy.git","svn_url":"https://github.com/erensezener/numpy","homepage":"http://www.numpy.org/","size":43240,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"numpy:master","ref":"master","sha":"c303c9b77afbc7fe6f4049683c3ccaabdebe7be3","user":{"login":"numpy","id":288276,"avatar_url":"https://avatars.githubusercontent.com/u/288276?v=3","gravatar_id":"","url":"https://api.github.com/users/numpy","html_url":"https://github.com/numpy","followers_url":"https://api.github.com/users/numpy/followers","following_url":"https://api.github.com/users/numpy/following{/other_user}","gists_url":"https://api.github.com/users/numpy/gists{/gist_id}","starred_url":"https://api.github.com/users/numpy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/numpy/subscriptions","organizations_url":"https://api.github.com/users/numpy/orgs","repos_url":"https://api.github.com/users/numpy/repos","events_url":"https://api.github.com/users/numpy/events{/privacy}","received_events_url":"https://api.github.com/users/numpy/received_events","type":"Organization","site_admin":false},"repo":{"id":908607,"name":"numpy","full_name":"numpy/numpy","owner":{"login":"numpy","id":288276,"avatar_url":"https://avatars.githubusercontent.com/u/288276?v=3","gravatar_id":"","url":"https://api.github.com/users/numpy","html_url":"https://github.com/numpy","followers_url":"https://api.github.com/users/numpy/followers","following_url":"https://api.github.com/users/numpy/following{/other_user}","gists_url":"https://api.github.com/users/numpy/gists{/gist_id}","starred_url":"https://api.github.com/users/numpy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/numpy/subscriptions","organizations_url":"https://api.github.com/users/numpy/orgs","repos_url":"https://api.github.com/users/numpy/repos","events_url":"https://api.github.com/users/numpy/events{/privacy}","received_events_url":"https://api.github.com/users/numpy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/numpy/numpy","description":"Numpy main repository","fork":false,"url":"https://api.github.com/repos/numpy/numpy","forks_url":"https://api.github.com/repos/numpy/numpy/forks","keys_url":"https://api.github.com/repos/numpy/numpy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/numpy/numpy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/numpy/numpy/teams","hooks_url":"https://api.github.com/repos/numpy/numpy/hooks","issue_events_url":"https://api.github.com/repos/numpy/numpy/issues/events{/number}","events_url":"https://api.github.com/repos/numpy/numpy/events","assignees_url":"https://api.github.com/repos/numpy/numpy/assignees{/user}","branches_url":"https://api.github.com/repos/numpy/numpy/branches{/branch}","tags_url":"https://api.github.com/repos/numpy/numpy/tags","blobs_url":"https://api.github.com/repos/numpy/numpy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/numpy/numpy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/numpy/numpy/git/refs{/sha}","trees_url":"https://api.github.com/repos/numpy/numpy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/numpy/numpy/statuses/{sha}","languages_url":"https://api.github.com/repos/numpy/numpy/languages","stargazers_url":"https://api.github.com/repos/numpy/numpy/stargazers","contributors_url":"https://api.github.com/repos/numpy/numpy/contributors","subscribers_url":"https://api.github.com/repos/numpy/numpy/subscribers","subscription_url":"https://api.github.com/repos/numpy/numpy/subscription","commits_url":"https://api.github.com/repos/numpy/numpy/commits{/sha}","git_commits_url":"https://api.github.com/repos/numpy/numpy/git/commits{/sha}","comments_url":"https://api.github.com/repos/numpy/numpy/comments{/number}","issue_comment_url":"https://api.github.com/repos/numpy/numpy/issues/comments{/number}","contents_url":"https://api.github.com/repos/numpy/numpy/contents/{+path}","compare_url":"https://api.github.com/repos/numpy/numpy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/numpy/numpy/merges","archive_url":"https://api.github.com/repos/numpy/numpy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/numpy/numpy/downloads","issues_url":"https://api.github.com/repos/numpy/numpy/issues{/number}","pulls_url":"https://api.github.com/repos/numpy/numpy/pulls{/number}","milestones_url":"https://api.github.com/repos/numpy/numpy/milestones{/number}","notifications_url":"https://api.github.com/repos/numpy/numpy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/numpy/numpy/labels{/name}","releases_url":"https://api.github.com/repos/numpy/numpy/releases{/id}","deployments_url":"https://api.github.com/repos/numpy/numpy/deployments","created_at":"2010-09-13T23:02:39Z","updated_at":"2016-02-26T14:47:19Z","pushed_at":"2016-02-27T00:53:48Z","git_url":"git://github.com/numpy/numpy.git","ssh_url":"git@github.com:numpy/numpy.git","clone_url":"https://github.com/numpy/numpy.git","svn_url":"https://github.com/numpy/numpy","homepage":"http://www.numpy.org/","size":64485,"stargazers_count":2672,"watchers_count":2672,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1397,"mirror_url":null,"open_issues_count":1152,"forks":1397,"open_issues":1152,"watchers":2672,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/numpy/numpy/pulls/7346"},"html":{"href":"https://github.com/numpy/numpy/pull/7346"},"issue":{"href":"https://api.github.com/repos/numpy/numpy/issues/7346"},"comments":{"href":"https://api.github.com/repos/numpy/numpy/issues/7346/comments"},"review_comments":{"href":"https://api.github.com/repos/numpy/numpy/pulls/7346/comments"},"review_comment":{"href":"https://api.github.com/repos/numpy/numpy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/numpy/numpy/pulls/7346/commits"},"statuses":{"href":"https://api.github.com/repos/numpy/numpy/statuses/dbcb2db706ebcd7bb6faf0c0fe207ca623ac61fc"}}}}