{"action":"created","comment":{"url":"https://api.github.com/repos/pfnet/chainer/pulls/comments/44663659","id":44663659,"diff_hunk":"@@ -1,7 +1,59 @@\n-# flake8: NOQA\n-# \"flake8: NOQA\" to suppress warning \"H104  File contains nothing but comments\"\n-\n # TODO(okuta): Implement tile\n \n+import collections\n+import six\n+\n+import cupy\n+\n+\n+def repeat(a, repeats, axis=None):\n+    \"\"\"Repeat arrays along an axis.\n+\n+    Args:\n+        a (cupy.ndarray): Array to transform.\n+        repeats (int, list or tuple): The number of repeats.\n+        axis (int): The axis to repeat.\n+\n+    Returns:\n+        cupy.ndarray: Transformed array with repeats.\n+\n+    .. seealso:: :func:`numpy.repeat`\n+\n+    \"\"\"\n+    if isinstance(repeats, int):\n+        if repeats < 0:\n+            raise ValueError(\n+                \"'repeats' should not be negative: {}\".format(repeats))\n+        if axis is None:\n+            b = a.reshape((-1, 1))\n+            ret = cupy.empty((len(b), repeats), dtype=b.dtype)\n+            ret[...] = b\n+            return ret.ravel()\n+\n+        repeats = [repeats] * a.shape[axis]\n+    elif isinstance(repeats, collections.Sequence):\n+        if any(rep < 0 for rep in repeats):\n+            raise ValueError(\n+                \"all elements of 'repeats' should not be negative: {}\"\n+                .format(repeats))\n+        if axis is None:\n+            raise ValueError(\n+                \"'axis' should be specified if 'repeats' is list or tuple\")\n+        if a.shape[axis] != len(repeats):\n+            raise ValueError(\n+                \"'repeats' and 'axis' of 'a' should be same length: {} != {}\"\n+                .format(a.shape[axis], len(repeats)))\n+    else:\n+        raise ValueError(\n+            \"'repeats' should be int or sequence: {}\".format(repeats))\n \n-# TODO(okuta): Implement repeat\n+    a_r = cupy.rollaxis(a, axis)\n+    ret_r_shape = list(a_r.shape)\n+    ret_r_shape[0] = sum(repeats)\n+    ret_r = cupy.zeros((ret_r_shape), dtype=a_r.dtype)\n+    for i in six.moves.xrange(a_r.shape[0]):","path":"cupy/manipulation/tiling.py","position":null,"original_position":58,"commit_id":"0acca7979ec51a88f4a8a71ed33b1aae02c7790e","original_commit_id":"5a8fbed1ece82f2201a8c9bd840c03eaba36bb8e","user":{"login":"okuta","id":7133388,"avatar_url":"https://avatars.githubusercontent.com/u/7133388?v=3","gravatar_id":"","url":"https://api.github.com/users/okuta","html_url":"https://github.com/okuta","followers_url":"https://api.github.com/users/okuta/followers","following_url":"https://api.github.com/users/okuta/following{/other_user}","gists_url":"https://api.github.com/users/okuta/gists{/gist_id}","starred_url":"https://api.github.com/users/okuta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/okuta/subscriptions","organizations_url":"https://api.github.com/users/okuta/orgs","repos_url":"https://api.github.com/users/okuta/repos","events_url":"https://api.github.com/users/okuta/events{/privacy}","received_events_url":"https://api.github.com/users/okuta/received_events","type":"User","site_admin":false},"body":"`len(a_r)` is better.","created_at":"2015-11-12T14:41:08Z","updated_at":"2015-11-12T14:41:08Z","html_url":"https://github.com/pfnet/chainer/pull/604#discussion_r44663659","pull_request_url":"https://api.github.com/repos/pfnet/chainer/pulls/604","_links":{"self":{"href":"https://api.github.com/repos/pfnet/chainer/pulls/comments/44663659"},"html":{"href":"https://github.com/pfnet/chainer/pull/604#discussion_r44663659"},"pull_request":{"href":"https://api.github.com/repos/pfnet/chainer/pulls/604"}}},"pull_request":{"url":"https://api.github.com/repos/pfnet/chainer/pulls/604","id":49864165,"html_url":"https://github.com/pfnet/chainer/pull/604","diff_url":"https://github.com/pfnet/chainer/pull/604.diff","patch_url":"https://github.com/pfnet/chainer/pull/604.patch","issue_url":"https://api.github.com/repos/pfnet/chainer/issues/604","number":604,"state":"open","locked":false,"title":"``repeat`` manipulation for cupy.ndarray","user":{"login":"wkentaro","id":4310419,"avatar_url":"https://avatars.githubusercontent.com/u/4310419?v=3","gravatar_id":"","url":"https://api.github.com/users/wkentaro","html_url":"https://github.com/wkentaro","followers_url":"https://api.github.com/users/wkentaro/followers","following_url":"https://api.github.com/users/wkentaro/following{/other_user}","gists_url":"https://api.github.com/users/wkentaro/gists{/gist_id}","starred_url":"https://api.github.com/users/wkentaro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wkentaro/subscriptions","organizations_url":"https://api.github.com/users/wkentaro/orgs","repos_url":"https://api.github.com/users/wkentaro/repos","events_url":"https://api.github.com/users/wkentaro/events{/privacy}","received_events_url":"https://api.github.com/users/wkentaro/received_events","type":"User","site_admin":false},"body":"Closes #603","created_at":"2015-11-05T18:50:59Z","updated_at":"2015-11-12T14:41:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1f500882fc3774f4285f8626e73b245b85c2d014","assignee":{"login":"okuta","id":7133388,"avatar_url":"https://avatars.githubusercontent.com/u/7133388?v=3","gravatar_id":"","url":"https://api.github.com/users/okuta","html_url":"https://github.com/okuta","followers_url":"https://api.github.com/users/okuta/followers","following_url":"https://api.github.com/users/okuta/following{/other_user}","gists_url":"https://api.github.com/users/okuta/gists{/gist_id}","starred_url":"https://api.github.com/users/okuta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/okuta/subscriptions","organizations_url":"https://api.github.com/users/okuta/orgs","repos_url":"https://api.github.com/users/okuta/repos","events_url":"https://api.github.com/users/okuta/events{/privacy}","received_events_url":"https://api.github.com/users/okuta/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/pfnet/chainer/milestones/10","html_url":"https://github.com/pfnet/chainer/milestones/v1.5.0","labels_url":"https://api.github.com/repos/pfnet/chainer/milestones/10/labels","id":1378838,"number":10,"title":"v1.5.0","description":"","creator":{"login":"unnonouno","id":740680,"avatar_url":"https://avatars.githubusercontent.com/u/740680?v=3","gravatar_id":"","url":"https://api.github.com/users/unnonouno","html_url":"https://github.com/unnonouno","followers_url":"https://api.github.com/users/unnonouno/followers","following_url":"https://api.github.com/users/unnonouno/following{/other_user}","gists_url":"https://api.github.com/users/unnonouno/gists{/gist_id}","starred_url":"https://api.github.com/users/unnonouno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/unnonouno/subscriptions","organizations_url":"https://api.github.com/users/unnonouno/orgs","repos_url":"https://api.github.com/users/unnonouno/repos","events_url":"https://api.github.com/users/unnonouno/events{/privacy}","received_events_url":"https://api.github.com/users/unnonouno/received_events","type":"User","site_admin":false},"open_issues":18,"closed_issues":5,"state":"open","created_at":"2015-10-27T09:03:54Z","updated_at":"2015-11-11T09:33:50Z","due_on":"2015-11-24T15:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/pfnet/chainer/pulls/604/commits","review_comments_url":"https://api.github.com/repos/pfnet/chainer/pulls/604/comments","review_comment_url":"https://api.github.com/repos/pfnet/chainer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pfnet/chainer/issues/604/comments","statuses_url":"https://api.github.com/repos/pfnet/chainer/statuses/0acca7979ec51a88f4a8a71ed33b1aae02c7790e","head":{"label":"wkentaro:cupy-repeat","ref":"cupy-repeat","sha":"0acca7979ec51a88f4a8a71ed33b1aae02c7790e","user":{"login":"wkentaro","id":4310419,"avatar_url":"https://avatars.githubusercontent.com/u/4310419?v=3","gravatar_id":"","url":"https://api.github.com/users/wkentaro","html_url":"https://github.com/wkentaro","followers_url":"https://api.github.com/users/wkentaro/followers","following_url":"https://api.github.com/users/wkentaro/following{/other_user}","gists_url":"https://api.github.com/users/wkentaro/gists{/gist_id}","starred_url":"https://api.github.com/users/wkentaro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wkentaro/subscriptions","organizations_url":"https://api.github.com/users/wkentaro/orgs","repos_url":"https://api.github.com/users/wkentaro/repos","events_url":"https://api.github.com/users/wkentaro/events{/privacy}","received_events_url":"https://api.github.com/users/wkentaro/received_events","type":"User","site_admin":false},"repo":{"id":45491173,"name":"chainer","full_name":"wkentaro/chainer","owner":{"login":"wkentaro","id":4310419,"avatar_url":"https://avatars.githubusercontent.com/u/4310419?v=3","gravatar_id":"","url":"https://api.github.com/users/wkentaro","html_url":"https://github.com/wkentaro","followers_url":"https://api.github.com/users/wkentaro/followers","following_url":"https://api.github.com/users/wkentaro/following{/other_user}","gists_url":"https://api.github.com/users/wkentaro/gists{/gist_id}","starred_url":"https://api.github.com/users/wkentaro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wkentaro/subscriptions","organizations_url":"https://api.github.com/users/wkentaro/orgs","repos_url":"https://api.github.com/users/wkentaro/repos","events_url":"https://api.github.com/users/wkentaro/events{/privacy}","received_events_url":"https://api.github.com/users/wkentaro/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wkentaro/chainer","description":"A flexible framework of neural networks for deep learning","fork":true,"url":"https://api.github.com/repos/wkentaro/chainer","forks_url":"https://api.github.com/repos/wkentaro/chainer/forks","keys_url":"https://api.github.com/repos/wkentaro/chainer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wkentaro/chainer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wkentaro/chainer/teams","hooks_url":"https://api.github.com/repos/wkentaro/chainer/hooks","issue_events_url":"https://api.github.com/repos/wkentaro/chainer/issues/events{/number}","events_url":"https://api.github.com/repos/wkentaro/chainer/events","assignees_url":"https://api.github.com/repos/wkentaro/chainer/assignees{/user}","branches_url":"https://api.github.com/repos/wkentaro/chainer/branches{/branch}","tags_url":"https://api.github.com/repos/wkentaro/chainer/tags","blobs_url":"https://api.github.com/repos/wkentaro/chainer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wkentaro/chainer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wkentaro/chainer/git/refs{/sha}","trees_url":"https://api.github.com/repos/wkentaro/chainer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wkentaro/chainer/statuses/{sha}","languages_url":"https://api.github.com/repos/wkentaro/chainer/languages","stargazers_url":"https://api.github.com/repos/wkentaro/chainer/stargazers","contributors_url":"https://api.github.com/repos/wkentaro/chainer/contributors","subscribers_url":"https://api.github.com/repos/wkentaro/chainer/subscribers","subscription_url":"https://api.github.com/repos/wkentaro/chainer/subscription","commits_url":"https://api.github.com/repos/wkentaro/chainer/commits{/sha}","git_commits_url":"https://api.github.com/repos/wkentaro/chainer/git/commits{/sha}","comments_url":"https://api.github.com/repos/wkentaro/chainer/comments{/number}","issue_comment_url":"https://api.github.com/repos/wkentaro/chainer/issues/comments{/number}","contents_url":"https://api.github.com/repos/wkentaro/chainer/contents/{+path}","compare_url":"https://api.github.com/repos/wkentaro/chainer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wkentaro/chainer/merges","archive_url":"https://api.github.com/repos/wkentaro/chainer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wkentaro/chainer/downloads","issues_url":"https://api.github.com/repos/wkentaro/chainer/issues{/number}","pulls_url":"https://api.github.com/repos/wkentaro/chainer/pulls{/number}","milestones_url":"https://api.github.com/repos/wkentaro/chainer/milestones{/number}","notifications_url":"https://api.github.com/repos/wkentaro/chainer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wkentaro/chainer/labels{/name}","releases_url":"https://api.github.com/repos/wkentaro/chainer/releases{/id}","created_at":"2015-11-03T19:43:33Z","updated_at":"2015-11-03T19:43:35Z","pushed_at":"2015-11-12T14:40:12Z","git_url":"git://github.com/wkentaro/chainer.git","ssh_url":"git@github.com:wkentaro/chainer.git","clone_url":"https://github.com/wkentaro/chainer.git","svn_url":"https://github.com/wkentaro/chainer","homepage":"http://chainer.org","size":3922,"stargazers_count":0,"watchers_count":0,"language":"Python","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":"pfnet:master","ref":"master","sha":"7c6b74d140ade72a7da75da2ac5529baf51c6f2b","user":{"login":"pfnet","id":9739572,"avatar_url":"https://avatars.githubusercontent.com/u/9739572?v=3","gravatar_id":"","url":"https://api.github.com/users/pfnet","html_url":"https://github.com/pfnet","followers_url":"https://api.github.com/users/pfnet/followers","following_url":"https://api.github.com/users/pfnet/following{/other_user}","gists_url":"https://api.github.com/users/pfnet/gists{/gist_id}","starred_url":"https://api.github.com/users/pfnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pfnet/subscriptions","organizations_url":"https://api.github.com/users/pfnet/orgs","repos_url":"https://api.github.com/users/pfnet/repos","events_url":"https://api.github.com/users/pfnet/events{/privacy}","received_events_url":"https://api.github.com/users/pfnet/received_events","type":"Organization","site_admin":false},"repo":{"id":36914478,"name":"chainer","full_name":"pfnet/chainer","owner":{"login":"pfnet","id":9739572,"avatar_url":"https://avatars.githubusercontent.com/u/9739572?v=3","gravatar_id":"","url":"https://api.github.com/users/pfnet","html_url":"https://github.com/pfnet","followers_url":"https://api.github.com/users/pfnet/followers","following_url":"https://api.github.com/users/pfnet/following{/other_user}","gists_url":"https://api.github.com/users/pfnet/gists{/gist_id}","starred_url":"https://api.github.com/users/pfnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pfnet/subscriptions","organizations_url":"https://api.github.com/users/pfnet/orgs","repos_url":"https://api.github.com/users/pfnet/repos","events_url":"https://api.github.com/users/pfnet/events{/privacy}","received_events_url":"https://api.github.com/users/pfnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pfnet/chainer","description":"A flexible framework of neural networks for deep learning","fork":false,"url":"https://api.github.com/repos/pfnet/chainer","forks_url":"https://api.github.com/repos/pfnet/chainer/forks","keys_url":"https://api.github.com/repos/pfnet/chainer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pfnet/chainer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pfnet/chainer/teams","hooks_url":"https://api.github.com/repos/pfnet/chainer/hooks","issue_events_url":"https://api.github.com/repos/pfnet/chainer/issues/events{/number}","events_url":"https://api.github.com/repos/pfnet/chainer/events","assignees_url":"https://api.github.com/repos/pfnet/chainer/assignees{/user}","branches_url":"https://api.github.com/repos/pfnet/chainer/branches{/branch}","tags_url":"https://api.github.com/repos/pfnet/chainer/tags","blobs_url":"https://api.github.com/repos/pfnet/chainer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pfnet/chainer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pfnet/chainer/git/refs{/sha}","trees_url":"https://api.github.com/repos/pfnet/chainer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pfnet/chainer/statuses/{sha}","languages_url":"https://api.github.com/repos/pfnet/chainer/languages","stargazers_url":"https://api.github.com/repos/pfnet/chainer/stargazers","contributors_url":"https://api.github.com/repos/pfnet/chainer/contributors","subscribers_url":"https://api.github.com/repos/pfnet/chainer/subscribers","subscription_url":"https://api.github.com/repos/pfnet/chainer/subscription","commits_url":"https://api.github.com/repos/pfnet/chainer/commits{/sha}","git_commits_url":"https://api.github.com/repos/pfnet/chainer/git/commits{/sha}","comments_url":"https://api.github.com/repos/pfnet/chainer/comments{/number}","issue_comment_url":"https://api.github.com/repos/pfnet/chainer/issues/comments{/number}","contents_url":"https://api.github.com/repos/pfnet/chainer/contents/{+path}","compare_url":"https://api.github.com/repos/pfnet/chainer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pfnet/chainer/merges","archive_url":"https://api.github.com/repos/pfnet/chainer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pfnet/chainer/downloads","issues_url":"https://api.github.com/repos/pfnet/chainer/issues{/number}","pulls_url":"https://api.github.com/repos/pfnet/chainer/pulls{/number}","milestones_url":"https://api.github.com/repos/pfnet/chainer/milestones{/number}","notifications_url":"https://api.github.com/repos/pfnet/chainer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pfnet/chainer/labels{/name}","releases_url":"https://api.github.com/repos/pfnet/chainer/releases{/id}","created_at":"2015-06-05T05:50:37Z","updated_at":"2015-11-12T13:52:33Z","pushed_at":"2015-11-12T14:40:12Z","git_url":"git://github.com/pfnet/chainer.git","ssh_url":"git@github.com:pfnet/chainer.git","clone_url":"https://github.com/pfnet/chainer.git","svn_url":"https://github.com/pfnet/chainer","homepage":"http://chainer.org","size":13886,"stargazers_count":900,"watchers_count":900,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":157,"mirror_url":null,"open_issues_count":98,"forks":157,"open_issues":98,"watchers":900,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pfnet/chainer/pulls/604"},"html":{"href":"https://github.com/pfnet/chainer/pull/604"},"issue":{"href":"https://api.github.com/repos/pfnet/chainer/issues/604"},"comments":{"href":"https://api.github.com/repos/pfnet/chainer/issues/604/comments"},"review_comments":{"href":"https://api.github.com/repos/pfnet/chainer/pulls/604/comments"},"review_comment":{"href":"https://api.github.com/repos/pfnet/chainer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pfnet/chainer/pulls/604/commits"},"statuses":{"href":"https://api.github.com/repos/pfnet/chainer/statuses/0acca7979ec51a88f4a8a71ed33b1aae02c7790e"}}}}