{"action":"created","comment":{"url":"https://api.github.com/repos/MDAnalysis/mdanalysis/pulls/comments/82285094","pull_request_review_id":3204347,"id":82285094,"diff_hunk":"@@ -17,13 +17,74 @@\n Topology object --- :mod:`MDAnalysis.core.topology'\n ===================================================================\n \n+\n+\"\"\"\n+\n \"\"\"\n+# second docstring == multiline comment\n+\n+TODO Notes:\n+  Could make downshift tables lazily built! This would\n+    a) Make these not get built when not used\n+    b) Optimise moving multiple atoms between residues as only built once afterwards\n+\n+  Could optimise moves by only updating the two parent tables rather than rebuilding everything!\n+\n+\n+\"\"\"\n+from six.moves import zip\n import numpy as np\n \n from ..lib.mdamath import one_to_many_pointers\n from .topologyattrs import Atomindices, Resindices, Segindices\n \n \n+def make_downshift_arrays(upshift):\n+    \"\"\"From an upwards translation table, create the opposite direction\n+\n+    Turns a many to one mapping (eg atoms to residues) to a one to many mapping\n+    (residues to atoms)\n+\n+    Parameters\n+    ----------\n+    upshift : array_like\n+        Array of integers describing which parent each item belongs to\n+\n+    Returns\n+    -------\n+    downshift : array_like (dtype object)\n+        An array of arrays, each containing the indices of the children\n+        of each parent\n+\n+    Examples\n+    --------\n+    \n+    To find the residue to atom mappings for a given atom to residue mapping:\n+\n+    >>> atom2res = np.array([0, 1, 0, 2, 2, 0, 2])\n+    >>> make_downshift_arrays(atom2res)\n+    array([array([0, 2, 5]), array([1]), array([3, 4, 6]), None], dtype=object)\n+\n+    Entry 0 corresponds to residue 0 and says that this contains atoms 0, 2 & 5\n+\n+    Notes\n+    -----\n+    The final entry in the return array will be ``None`` to ensure that the\n+    dtype of the array is object.  This means negative indexing should\n+    not be used ever with these arrays.\n+    \"\"\"\n+    order = np.argsort(upshift)\n+\n+    upshift_sorted = upshift[order]\n+    borders = [None] + list(np.nonzero(np.diff(upshift_sorted))[0] + 1) + [None]\n+\n+    # returns an array of arrays\n+    # Add None to end of array to force it to be of type Object\n+    # Without this, a rectangular array gets squashed into a single array\n+    return np.array([np.array(order[x:y], copy=True, dtype=np.int)\n+                     for x, y in zip(borders[:-1], borders[1:])] + [None],","path":"package/MDAnalysis/core/topology.py","position":69,"original_position":69,"commit_id":"ab87d4a5b2bc24a0449007c1a810fa1fd65086de","original_commit_id":"ab87d4a5b2bc24a0449007c1a810fa1fd65086de","user":{"login":"richardjgowers","id":9249543,"avatar_url":"https://avatars.githubusercontent.com/u/9249543?v=3","gravatar_id":"","url":"https://api.github.com/users/richardjgowers","html_url":"https://github.com/richardjgowers","followers_url":"https://api.github.com/users/richardjgowers/followers","following_url":"https://api.github.com/users/richardjgowers/following{/other_user}","gists_url":"https://api.github.com/users/richardjgowers/gists{/gist_id}","starred_url":"https://api.github.com/users/richardjgowers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richardjgowers/subscriptions","organizations_url":"https://api.github.com/users/richardjgowers/orgs","repos_url":"https://api.github.com/users/richardjgowers/repos","events_url":"https://api.github.com/users/richardjgowers/events{/privacy}","received_events_url":"https://api.github.com/users/richardjgowers/received_events","type":"User","site_admin":false},"body":"@khuston so this is where atom order gets stored.  If this doesn't come out ordered, then we just need to change this to `np.array([np.sort(order[x:y]) for x, y etc))`","created_at":"2016-10-06T21:05:59Z","updated_at":"2016-10-06T21:05:59Z","html_url":"https://github.com/MDAnalysis/mdanalysis/pull/967#discussion_r82285094","pull_request_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/pulls/967","_links":{"self":{"href":"https://api.github.com/repos/MDAnalysis/mdanalysis/pulls/comments/82285094"},"html":{"href":"https://github.com/MDAnalysis/mdanalysis/pull/967#discussion_r82285094"},"pull_request":{"href":"https://api.github.com/repos/MDAnalysis/mdanalysis/pulls/967"}}},"pull_request":{"url":"https://api.github.com/repos/MDAnalysis/mdanalysis/pulls/967","id":83829397,"html_url":"https://github.com/MDAnalysis/mdanalysis/pull/967","diff_url":"https://github.com/MDAnalysis/mdanalysis/pull/967.diff","patch_url":"https://github.com/MDAnalysis/mdanalysis/pull/967.patch","issue_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues/967","number":967,"state":"open","locked":false,"title":"Issue 363 resmove","user":{"login":"richardjgowers","id":9249543,"avatar_url":"https://avatars.githubusercontent.com/u/9249543?v=3","gravatar_id":"","url":"https://api.github.com/users/richardjgowers","html_url":"https://github.com/richardjgowers","followers_url":"https://api.github.com/users/richardjgowers/followers","following_url":"https://api.github.com/users/richardjgowers/following{/other_user}","gists_url":"https://api.github.com/users/richardjgowers/gists{/gist_id}","starred_url":"https://api.github.com/users/richardjgowers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richardjgowers/subscriptions","organizations_url":"https://api.github.com/users/richardjgowers/orgs","repos_url":"https://api.github.com/users/richardjgowers/repos","events_url":"https://api.github.com/users/richardjgowers/events{/privacy}","received_events_url":"https://api.github.com/users/richardjgowers/received_events","type":"User","site_admin":false},"body":"Fixes - moving atoms between residues\r\n\r\nAtoms can be moved between residues by setting either the resid (as before) or resindex\r\nResidues can be moved via either the segid or segindex\r\n\r\nCurrently only works on moves to existing residues/segments\r\n\r\nPR Checklist\r\n------------\r\n - [x] Tests?\r\n - [x] Docs?\r\n - [x] CHANGELOG updated?\r\n - [x] Issue raised/referenced?\r\n","created_at":"2016-09-02T16:27:31Z","updated_at":"2016-10-06T21:05:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dc0ee961c73c3c2d2111c02efb1b21faa12648c5","assignee":{"login":"kain88-de","id":4302678,"avatar_url":"https://avatars.githubusercontent.com/u/4302678?v=3","gravatar_id":"","url":"https://api.github.com/users/kain88-de","html_url":"https://github.com/kain88-de","followers_url":"https://api.github.com/users/kain88-de/followers","following_url":"https://api.github.com/users/kain88-de/following{/other_user}","gists_url":"https://api.github.com/users/kain88-de/gists{/gist_id}","starred_url":"https://api.github.com/users/kain88-de/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kain88-de/subscriptions","organizations_url":"https://api.github.com/users/kain88-de/orgs","repos_url":"https://api.github.com/users/kain88-de/repos","events_url":"https://api.github.com/users/kain88-de/events{/privacy}","received_events_url":"https://api.github.com/users/kain88-de/received_events","type":"User","site_admin":false},"assignees":[{"login":"kain88-de","id":4302678,"avatar_url":"https://avatars.githubusercontent.com/u/4302678?v=3","gravatar_id":"","url":"https://api.github.com/users/kain88-de","html_url":"https://github.com/kain88-de","followers_url":"https://api.github.com/users/kain88-de/followers","following_url":"https://api.github.com/users/kain88-de/following{/other_user}","gists_url":"https://api.github.com/users/kain88-de/gists{/gist_id}","starred_url":"https://api.github.com/users/kain88-de/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kain88-de/subscriptions","organizations_url":"https://api.github.com/users/kain88-de/orgs","repos_url":"https://api.github.com/users/kain88-de/repos","events_url":"https://api.github.com/users/kain88-de/events{/privacy}","received_events_url":"https://api.github.com/users/kain88-de/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/pulls/967/commits","review_comments_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/pulls/967/comments","review_comment_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/pulls/comments{/number}","comments_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues/967/comments","statuses_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/statuses/ab87d4a5b2bc24a0449007c1a810fa1fd65086de","head":{"label":"MDAnalysis:issue-363-resmove","ref":"issue-363-resmove","sha":"ab87d4a5b2bc24a0449007c1a810fa1fd65086de","user":{"login":"MDAnalysis","id":11445951,"avatar_url":"https://avatars.githubusercontent.com/u/11445951?v=3","gravatar_id":"","url":"https://api.github.com/users/MDAnalysis","html_url":"https://github.com/MDAnalysis","followers_url":"https://api.github.com/users/MDAnalysis/followers","following_url":"https://api.github.com/users/MDAnalysis/following{/other_user}","gists_url":"https://api.github.com/users/MDAnalysis/gists{/gist_id}","starred_url":"https://api.github.com/users/MDAnalysis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MDAnalysis/subscriptions","organizations_url":"https://api.github.com/users/MDAnalysis/orgs","repos_url":"https://api.github.com/users/MDAnalysis/repos","events_url":"https://api.github.com/users/MDAnalysis/events{/privacy}","received_events_url":"https://api.github.com/users/MDAnalysis/received_events","type":"Organization","site_admin":false},"repo":{"id":33389183,"name":"mdanalysis","full_name":"MDAnalysis/mdanalysis","owner":{"login":"MDAnalysis","id":11445951,"avatar_url":"https://avatars.githubusercontent.com/u/11445951?v=3","gravatar_id":"","url":"https://api.github.com/users/MDAnalysis","html_url":"https://github.com/MDAnalysis","followers_url":"https://api.github.com/users/MDAnalysis/followers","following_url":"https://api.github.com/users/MDAnalysis/following{/other_user}","gists_url":"https://api.github.com/users/MDAnalysis/gists{/gist_id}","starred_url":"https://api.github.com/users/MDAnalysis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MDAnalysis/subscriptions","organizations_url":"https://api.github.com/users/MDAnalysis/orgs","repos_url":"https://api.github.com/users/MDAnalysis/repos","events_url":"https://api.github.com/users/MDAnalysis/events{/privacy}","received_events_url":"https://api.github.com/users/MDAnalysis/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MDAnalysis/mdanalysis","description":"MDAnalysis is a Python library to analyze molecular dynamics trajectories.","fork":false,"url":"https://api.github.com/repos/MDAnalysis/mdanalysis","forks_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/forks","keys_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/teams","hooks_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/hooks","issue_events_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues/events{/number}","events_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/events","assignees_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/assignees{/user}","branches_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/branches{/branch}","tags_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/tags","blobs_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/git/refs{/sha}","trees_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/statuses/{sha}","languages_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/languages","stargazers_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/stargazers","contributors_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/contributors","subscribers_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/subscribers","subscription_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/subscription","commits_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/commits{/sha}","git_commits_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/git/commits{/sha}","comments_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/comments{/number}","issue_comment_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues/comments{/number}","contents_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/contents/{+path}","compare_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/merges","archive_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/downloads","issues_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues{/number}","pulls_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/pulls{/number}","milestones_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/milestones{/number}","notifications_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/labels{/name}","releases_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/releases{/id}","deployments_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/deployments","created_at":"2015-04-04T00:39:41Z","updated_at":"2016-10-06T11:08:05Z","pushed_at":"2016-10-06T21:03:01Z","git_url":"git://github.com/MDAnalysis/mdanalysis.git","ssh_url":"git@github.com:MDAnalysis/mdanalysis.git","clone_url":"https://github.com/MDAnalysis/mdanalysis.git","svn_url":"https://github.com/MDAnalysis/mdanalysis","homepage":"http://www.mdanalysis.org","size":324362,"stargazers_count":84,"watchers_count":84,"language":"Python","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":true,"forks_count":60,"mirror_url":null,"open_issues_count":148,"forks":60,"open_issues":148,"watchers":84,"default_branch":"develop"}},"base":{"label":"MDAnalysis:issue-363","ref":"issue-363","sha":"9c5594145b4b9efe6fbed2fb32c7904050c8191e","user":{"login":"MDAnalysis","id":11445951,"avatar_url":"https://avatars.githubusercontent.com/u/11445951?v=3","gravatar_id":"","url":"https://api.github.com/users/MDAnalysis","html_url":"https://github.com/MDAnalysis","followers_url":"https://api.github.com/users/MDAnalysis/followers","following_url":"https://api.github.com/users/MDAnalysis/following{/other_user}","gists_url":"https://api.github.com/users/MDAnalysis/gists{/gist_id}","starred_url":"https://api.github.com/users/MDAnalysis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MDAnalysis/subscriptions","organizations_url":"https://api.github.com/users/MDAnalysis/orgs","repos_url":"https://api.github.com/users/MDAnalysis/repos","events_url":"https://api.github.com/users/MDAnalysis/events{/privacy}","received_events_url":"https://api.github.com/users/MDAnalysis/received_events","type":"Organization","site_admin":false},"repo":{"id":33389183,"name":"mdanalysis","full_name":"MDAnalysis/mdanalysis","owner":{"login":"MDAnalysis","id":11445951,"avatar_url":"https://avatars.githubusercontent.com/u/11445951?v=3","gravatar_id":"","url":"https://api.github.com/users/MDAnalysis","html_url":"https://github.com/MDAnalysis","followers_url":"https://api.github.com/users/MDAnalysis/followers","following_url":"https://api.github.com/users/MDAnalysis/following{/other_user}","gists_url":"https://api.github.com/users/MDAnalysis/gists{/gist_id}","starred_url":"https://api.github.com/users/MDAnalysis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MDAnalysis/subscriptions","organizations_url":"https://api.github.com/users/MDAnalysis/orgs","repos_url":"https://api.github.com/users/MDAnalysis/repos","events_url":"https://api.github.com/users/MDAnalysis/events{/privacy}","received_events_url":"https://api.github.com/users/MDAnalysis/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MDAnalysis/mdanalysis","description":"MDAnalysis is a Python library to analyze molecular dynamics trajectories.","fork":false,"url":"https://api.github.com/repos/MDAnalysis/mdanalysis","forks_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/forks","keys_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/teams","hooks_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/hooks","issue_events_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues/events{/number}","events_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/events","assignees_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/assignees{/user}","branches_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/branches{/branch}","tags_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/tags","blobs_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/git/refs{/sha}","trees_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/statuses/{sha}","languages_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/languages","stargazers_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/stargazers","contributors_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/contributors","subscribers_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/subscribers","subscription_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/subscription","commits_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/commits{/sha}","git_commits_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/git/commits{/sha}","comments_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/comments{/number}","issue_comment_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues/comments{/number}","contents_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/contents/{+path}","compare_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/merges","archive_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/downloads","issues_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues{/number}","pulls_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/pulls{/number}","milestones_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/milestones{/number}","notifications_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/labels{/name}","releases_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/releases{/id}","deployments_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/deployments","created_at":"2015-04-04T00:39:41Z","updated_at":"2016-10-06T11:08:05Z","pushed_at":"2016-10-06T21:03:01Z","git_url":"git://github.com/MDAnalysis/mdanalysis.git","ssh_url":"git@github.com:MDAnalysis/mdanalysis.git","clone_url":"https://github.com/MDAnalysis/mdanalysis.git","svn_url":"https://github.com/MDAnalysis/mdanalysis","homepage":"http://www.mdanalysis.org","size":324362,"stargazers_count":84,"watchers_count":84,"language":"Python","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":true,"forks_count":60,"mirror_url":null,"open_issues_count":148,"forks":60,"open_issues":148,"watchers":84,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/MDAnalysis/mdanalysis/pulls/967"},"html":{"href":"https://github.com/MDAnalysis/mdanalysis/pull/967"},"issue":{"href":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues/967"},"comments":{"href":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues/967/comments"},"review_comments":{"href":"https://api.github.com/repos/MDAnalysis/mdanalysis/pulls/967/comments"},"review_comment":{"href":"https://api.github.com/repos/MDAnalysis/mdanalysis/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/MDAnalysis/mdanalysis/pulls/967/commits"},"statuses":{"href":"https://api.github.com/repos/MDAnalysis/mdanalysis/statuses/ab87d4a5b2bc24a0449007c1a810fa1fd65086de"}}}}
{"actor":{"display_login":"richardjgowers"}}