{"action":"created","comment":{"url":"https://api.github.com/repos/numpy/numpy/pulls/comments/44233754","id":44233754,"diff_hunk":"@@ -1455,6 +1459,93 @@ def rollaxis(a, axis, start=0):\n     return a.transpose(axes)\n \n \n+def _validate_axis(axis, ndim, argname):\n+    if isinstance(axis, int) or getattr(axis, 'ndim', 1) == 0:\n+        axis = [axis]\n+    axis = list(axis)","path":"numpy/core/numeric.py","position":null,"original_position":59,"commit_id":"13e9b3729289bcce512d77be2a6248b7197e8ce7","original_commit_id":"cd34e53665163d98c232ef892460788be2ffb8fa","user":{"login":"shoyer","id":1217238,"avatar_url":"https://avatars.githubusercontent.com/u/1217238?v=3","gravatar_id":"","url":"https://api.github.com/users/shoyer","html_url":"https://github.com/shoyer","followers_url":"https://api.github.com/users/shoyer/followers","following_url":"https://api.github.com/users/shoyer/following{/other_user}","gists_url":"https://api.github.com/users/shoyer/gists{/gist_id}","starred_url":"https://api.github.com/users/shoyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shoyer/subscriptions","organizations_url":"https://api.github.com/users/shoyer/orgs","repos_url":"https://api.github.com/users/shoyer/repos","events_url":"https://api.github.com/users/shoyer/events{/privacy}","received_events_url":"https://api.github.com/users/shoyer/received_events","type":"User","site_admin":false},"body":"@seberg  agreed, fixed","created_at":"2015-11-09T00:18:28Z","updated_at":"2015-11-09T00:18:28Z","html_url":"https://github.com/numpy/numpy/pull/6630#discussion_r44233754","pull_request_url":"https://api.github.com/repos/numpy/numpy/pulls/6630","_links":{"self":{"href":"https://api.github.com/repos/numpy/numpy/pulls/comments/44233754"},"html":{"href":"https://github.com/numpy/numpy/pull/6630#discussion_r44233754"},"pull_request":{"href":"https://api.github.com/repos/numpy/numpy/pulls/6630"}}},"pull_request":{"url":"https://api.github.com/repos/numpy/numpy/pulls/6630","id":49782725,"html_url":"https://github.com/numpy/numpy/pull/6630","diff_url":"https://github.com/numpy/numpy/pull/6630.diff","patch_url":"https://github.com/numpy/numpy/pull/6630.patch","issue_url":"https://api.github.com/repos/numpy/numpy/issues/6630","number":6630,"state":"open","locked":false,"title":"ENH: moveaxis function","user":{"login":"shoyer","id":1217238,"avatar_url":"https://avatars.githubusercontent.com/u/1217238?v=3","gravatar_id":"","url":"https://api.github.com/users/shoyer","html_url":"https://github.com/shoyer","followers_url":"https://api.github.com/users/shoyer/followers","following_url":"https://api.github.com/users/shoyer/following{/other_user}","gists_url":"https://api.github.com/users/shoyer/gists{/gist_id}","starred_url":"https://api.github.com/users/shoyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shoyer/subscriptions","organizations_url":"https://api.github.com/users/shoyer/orgs","repos_url":"https://api.github.com/users/shoyer/repos","events_url":"https://api.github.com/users/shoyer/events{/privacy}","received_events_url":"https://api.github.com/users/shoyer/received_events","type":"User","site_admin":false},"body":"Fixes #2039\r\n\r\nThis function provides a much more intuitive interface than `np.rollaxis`, which has a confusing behavior with the position of the `start` argument:\r\nhttp://stackoverflow.com/questions/29891583/reason-why-numpy-rollaxis-is-so-confusing\r\n\r\nIn particular, it makes it easy to move the first axis to the end without reordering the other axes: `moveaxis(a, 0, -1)` (compare to `rollaxis(a, 0, a.ndim)`). It is also a better name name for moving axes than `rollaxis`.\r\n\r\nThis functionality, and even the specific name `rollaxis` was independently suggested several times over the years in discussions on the mailing list and GitHub (#2039), but never made it into a pull request:\r\nhttps://mail.scipy.org/pipermail/numpy-discussion/2010-September/052882.html\r\n\r\nMy version adds support for a sequence of axis arguments. I find this behavior convenient, e.g., to move the first two axes of an array to the end, use `moveaxis(a, [0, 1], [-2, -1])`. The ability to specific source and destination locations is often more intuitive than supplying a list of arguments to `transpose`. This also allows us to nicely generalize NumPy's existing axis manipulation routines:\r\n```python\r\ndef transpose(a, order=None):\r\n    if order is None:\r\n        order = reversed(range(a.ndim))\r\n    return moveaxes(a, order, range(a.ndim))\r\n\r\ndef swapaxes(a, axis1, axis2):\r\n    return moveaxes(a, [axis1, axis2], [axis2, axis1])\r\n\r\ndef rollaxis(a, axis, start=0):\r\n    if axis < start:\r\n        start -= 1\r\n    return moveaxes(a, axis, start)\r\n```","created_at":"2015-11-05T05:00:46Z","updated_at":"2015-11-09T00:18:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3ac64f4240b3b19655e5baa87180f25dc003e8ef","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/numpy/numpy/pulls/6630/commits","review_comments_url":"https://api.github.com/repos/numpy/numpy/pulls/6630/comments","review_comment_url":"https://api.github.com/repos/numpy/numpy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/numpy/numpy/issues/6630/comments","statuses_url":"https://api.github.com/repos/numpy/numpy/statuses/13e9b3729289bcce512d77be2a6248b7197e8ce7","head":{"label":"shoyer:moveaxis","ref":"moveaxis","sha":"13e9b3729289bcce512d77be2a6248b7197e8ce7","user":{"login":"shoyer","id":1217238,"avatar_url":"https://avatars.githubusercontent.com/u/1217238?v=3","gravatar_id":"","url":"https://api.github.com/users/shoyer","html_url":"https://github.com/shoyer","followers_url":"https://api.github.com/users/shoyer/followers","following_url":"https://api.github.com/users/shoyer/following{/other_user}","gists_url":"https://api.github.com/users/shoyer/gists{/gist_id}","starred_url":"https://api.github.com/users/shoyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shoyer/subscriptions","organizations_url":"https://api.github.com/users/shoyer/orgs","repos_url":"https://api.github.com/users/shoyer/repos","events_url":"https://api.github.com/users/shoyer/events{/privacy}","received_events_url":"https://api.github.com/users/shoyer/received_events","type":"User","site_admin":false},"repo":{"id":17073121,"name":"numpy","full_name":"shoyer/numpy","owner":{"login":"shoyer","id":1217238,"avatar_url":"https://avatars.githubusercontent.com/u/1217238?v=3","gravatar_id":"","url":"https://api.github.com/users/shoyer","html_url":"https://github.com/shoyer","followers_url":"https://api.github.com/users/shoyer/followers","following_url":"https://api.github.com/users/shoyer/following{/other_user}","gists_url":"https://api.github.com/users/shoyer/gists{/gist_id}","starred_url":"https://api.github.com/users/shoyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shoyer/subscriptions","organizations_url":"https://api.github.com/users/shoyer/orgs","repos_url":"https://api.github.com/users/shoyer/repos","events_url":"https://api.github.com/users/shoyer/events{/privacy}","received_events_url":"https://api.github.com/users/shoyer/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/shoyer/numpy","description":"Numpy main repository","fork":true,"url":"https://api.github.com/repos/shoyer/numpy","forks_url":"https://api.github.com/repos/shoyer/numpy/forks","keys_url":"https://api.github.com/repos/shoyer/numpy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shoyer/numpy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shoyer/numpy/teams","hooks_url":"https://api.github.com/repos/shoyer/numpy/hooks","issue_events_url":"https://api.github.com/repos/shoyer/numpy/issues/events{/number}","events_url":"https://api.github.com/repos/shoyer/numpy/events","assignees_url":"https://api.github.com/repos/shoyer/numpy/assignees{/user}","branches_url":"https://api.github.com/repos/shoyer/numpy/branches{/branch}","tags_url":"https://api.github.com/repos/shoyer/numpy/tags","blobs_url":"https://api.github.com/repos/shoyer/numpy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shoyer/numpy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shoyer/numpy/git/refs{/sha}","trees_url":"https://api.github.com/repos/shoyer/numpy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shoyer/numpy/statuses/{sha}","languages_url":"https://api.github.com/repos/shoyer/numpy/languages","stargazers_url":"https://api.github.com/repos/shoyer/numpy/stargazers","contributors_url":"https://api.github.com/repos/shoyer/numpy/contributors","subscribers_url":"https://api.github.com/repos/shoyer/numpy/subscribers","subscription_url":"https://api.github.com/repos/shoyer/numpy/subscription","commits_url":"https://api.github.com/repos/shoyer/numpy/commits{/sha}","git_commits_url":"https://api.github.com/repos/shoyer/numpy/git/commits{/sha}","comments_url":"https://api.github.com/repos/shoyer/numpy/comments{/number}","issue_comment_url":"https://api.github.com/repos/shoyer/numpy/issues/comments{/number}","contents_url":"https://api.github.com/repos/shoyer/numpy/contents/{+path}","compare_url":"https://api.github.com/repos/shoyer/numpy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shoyer/numpy/merges","archive_url":"https://api.github.com/repos/shoyer/numpy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shoyer/numpy/downloads","issues_url":"https://api.github.com/repos/shoyer/numpy/issues{/number}","pulls_url":"https://api.github.com/repos/shoyer/numpy/pulls{/number}","milestones_url":"https://api.github.com/repos/shoyer/numpy/milestones{/number}","notifications_url":"https://api.github.com/repos/shoyer/numpy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shoyer/numpy/labels{/name}","releases_url":"https://api.github.com/repos/shoyer/numpy/releases{/id}","created_at":"2014-02-21T23:15:13Z","updated_at":"2015-02-25T08:34:01Z","pushed_at":"2015-11-09T00:17:59Z","git_url":"git://github.com/shoyer/numpy.git","ssh_url":"git@github.com:shoyer/numpy.git","clone_url":"https://github.com/shoyer/numpy.git","svn_url":"https://github.com/shoyer/numpy","homepage":"http://www.numpy.org/","size":41785,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"numpy:master","ref":"master","sha":"615e66b19defa2d9fbfa94d6118fb6243ae90ffe","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}","created_at":"2010-09-13T23:02:39Z","updated_at":"2015-11-08T21:23:47Z","pushed_at":"2015-11-09T00:18:02Z","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":88097,"stargazers_count":2297,"watchers_count":2297,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1197,"mirror_url":null,"open_issues_count":1041,"forks":1197,"open_issues":1041,"watchers":2297,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/numpy/numpy/pulls/6630"},"html":{"href":"https://github.com/numpy/numpy/pull/6630"},"issue":{"href":"https://api.github.com/repos/numpy/numpy/issues/6630"},"comments":{"href":"https://api.github.com/repos/numpy/numpy/issues/6630/comments"},"review_comments":{"href":"https://api.github.com/repos/numpy/numpy/pulls/6630/comments"},"review_comment":{"href":"https://api.github.com/repos/numpy/numpy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/numpy/numpy/pulls/6630/commits"},"statuses":{"href":"https://api.github.com/repos/numpy/numpy/statuses/13e9b3729289bcce512d77be2a6248b7197e8ce7"}}}}