{"action":"created","comment":{"url":"https://api.github.com/repos/nkeim/trackpy/pulls/comments/44320637","id":44320637,"diff_hunk":"@@ -0,0 +1,130 @@\n+from scipy.spatial import cKDTree\n+import random\n+import numpy as np\n+from warnings import warn\n+\n+\n+\n+def pairCorrelation2D(feat, fraction = 1., dr = .5, cutoff = 20., ndensity=None, boundary = None):\n+    \"\"\"\n+    Calculate the pair correlation function in 2 dimensions.\n+\n+    Parameters\n+    ----------\n+    feat : Pandas DataFrame\n+        DataFrame containing the x and y coordinates of particles\n+    fration : float, optional\n+        The fraction of particles to calculate g(r) with. May be used to increase speed of function. Particles selected at random.\n+    dr : float, optional\n+        The bin width\n+    cutoff : float, optional\n+        Maximum distance to calculate g(r)\n+    ndensity : float, optional\n+        Density of particle packing. If not specified, density will be calculated assuming rectangular homogenous arangement\n+    boundary : Tuple, optional\n+        Tuple specifying rectangular boundary of partcicles (xmin, xmax, ymin, ymax)\n+\n+    Returns\n+    -------\n+    r_edges : array\n+        Return the bin edges\n+    g_r : array\n+        The values of g_r\n+    \"\"\"\n+\n+    if boundary is None:\n+        warn(\"Rectangular packing is assumed. Boundaries are determined by edge particles.\")\n+        xmin = feat.x.min()\n+        xmax = feat.x.max()\n+        ymin = feat.y.min()\n+        ymax = feat.y.max()\n+    else:\n+        xmin = boundary[0]\n+        xmax = boundary[1]\n+        ymin = boundary[2]\n+        ymax = boundary[3]\n+\n+    if ndensity is None:\n+        ndensity = feat.x.count() / ((feat.x.max() - feat.x.min()) * (feat.y.max() - feat.y.min())) #particle packing density\n+        warn(\"Rectangular homogenous packing is assumed to calculate particle density.\")\n+\n+\n+    p_indexes = random.sample(range(len(feat)), int(fraction*len(feat))) #grab random sample of particles\n+    r_edges = np.arange(dr, cutoff + 2*dr, dr) #radii to search for particles\n+    g_r = np.zeros(len(r_edges) - 1)\n+    max_p_count =  int(np.pi * (r_edges.max() + dr)**2 * ndensity * 10) #upper bound for neighborhood particle count\n+    ckdtree = cKDTree(feat[['x', 'y']])#initialize kdtree","path":"trackpy/packing.py","position":56,"original_position":56,"commit_id":"9a2bae468d99851bdb29bb00a9519991854567d1","original_commit_id":"9a2bae468d99851bdb29bb00a9519991854567d1","user":{"login":"nkeim","id":2985325,"avatar_url":"https://avatars.githubusercontent.com/u/2985325?v=3","gravatar_id":"","url":"https://api.github.com/users/nkeim","html_url":"https://github.com/nkeim","followers_url":"https://api.github.com/users/nkeim/followers","following_url":"https://api.github.com/users/nkeim/following{/other_user}","gists_url":"https://api.github.com/users/nkeim/gists{/gist_id}","starred_url":"https://api.github.com/users/nkeim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nkeim/subscriptions","organizations_url":"https://api.github.com/users/nkeim/orgs","repos_url":"https://api.github.com/users/nkeim/repos","events_url":"https://api.github.com/users/nkeim/events{/privacy}","received_events_url":"https://api.github.com/users/nkeim/received_events","type":"User","site_admin":false},"body":"You should take a look at the PEP8 conventions. We follow them loosely; see the [information for contributors](https://github.com/soft-matter/trackpy/wiki/Information-for-contributors). One convention trackpy generally adheres to is to put two spaces before an inline comment, and one space between the \"#\" and the comment text.","created_at":"2015-11-09T19:42:32Z","updated_at":"2015-11-09T19:42:32Z","html_url":"https://github.com/nkeim/trackpy/pull/4#discussion_r44320637","pull_request_url":"https://api.github.com/repos/nkeim/trackpy/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/nkeim/trackpy/pulls/comments/44320637"},"html":{"href":"https://github.com/nkeim/trackpy/pull/4#discussion_r44320637"},"pull_request":{"href":"https://api.github.com/repos/nkeim/trackpy/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/nkeim/trackpy/pulls/4","id":50038844,"html_url":"https://github.com/nkeim/trackpy/pull/4","diff_url":"https://github.com/nkeim/trackpy/pull/4.diff","patch_url":"https://github.com/nkeim/trackpy/pull/4.patch","issue_url":"https://api.github.com/repos/nkeim/trackpy/issues/4","number":4,"state":"open","locked":false,"title":"Added packing module","user":{"login":"dwieker","id":6488287,"avatar_url":"https://avatars.githubusercontent.com/u/6488287?v=3","gravatar_id":"","url":"https://api.github.com/users/dwieker","html_url":"https://github.com/dwieker","followers_url":"https://api.github.com/users/dwieker/followers","following_url":"https://api.github.com/users/dwieker/following{/other_user}","gists_url":"https://api.github.com/users/dwieker/gists{/gist_id}","starred_url":"https://api.github.com/users/dwieker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dwieker/subscriptions","organizations_url":"https://api.github.com/users/dwieker/orgs","repos_url":"https://api.github.com/users/dwieker/repos","events_url":"https://api.github.com/users/dwieker/events{/privacy}","received_events_url":"https://api.github.com/users/dwieker/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-11-07T16:04:04Z","updated_at":"2015-11-09T19:42:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"121fe112726d152602f2d34485e1918505f2fd17","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/nkeim/trackpy/pulls/4/commits","review_comments_url":"https://api.github.com/repos/nkeim/trackpy/pulls/4/comments","review_comment_url":"https://api.github.com/repos/nkeim/trackpy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nkeim/trackpy/issues/4/comments","statuses_url":"https://api.github.com/repos/nkeim/trackpy/statuses/9a2bae468d99851bdb29bb00a9519991854567d1","head":{"label":"dwieker:master","ref":"master","sha":"9a2bae468d99851bdb29bb00a9519991854567d1","user":{"login":"dwieker","id":6488287,"avatar_url":"https://avatars.githubusercontent.com/u/6488287?v=3","gravatar_id":"","url":"https://api.github.com/users/dwieker","html_url":"https://github.com/dwieker","followers_url":"https://api.github.com/users/dwieker/followers","following_url":"https://api.github.com/users/dwieker/following{/other_user}","gists_url":"https://api.github.com/users/dwieker/gists{/gist_id}","starred_url":"https://api.github.com/users/dwieker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dwieker/subscriptions","organizations_url":"https://api.github.com/users/dwieker/orgs","repos_url":"https://api.github.com/users/dwieker/repos","events_url":"https://api.github.com/users/dwieker/events{/privacy}","received_events_url":"https://api.github.com/users/dwieker/received_events","type":"User","site_admin":false},"repo":{"id":45742801,"name":"trackpy","full_name":"dwieker/trackpy","owner":{"login":"dwieker","id":6488287,"avatar_url":"https://avatars.githubusercontent.com/u/6488287?v=3","gravatar_id":"","url":"https://api.github.com/users/dwieker","html_url":"https://github.com/dwieker","followers_url":"https://api.github.com/users/dwieker/followers","following_url":"https://api.github.com/users/dwieker/following{/other_user}","gists_url":"https://api.github.com/users/dwieker/gists{/gist_id}","starred_url":"https://api.github.com/users/dwieker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dwieker/subscriptions","organizations_url":"https://api.github.com/users/dwieker/orgs","repos_url":"https://api.github.com/users/dwieker/repos","events_url":"https://api.github.com/users/dwieker/events{/privacy}","received_events_url":"https://api.github.com/users/dwieker/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dwieker/trackpy","description":"An impure python implementation of Crocker-Grier for single particle tracking","fork":true,"url":"https://api.github.com/repos/dwieker/trackpy","forks_url":"https://api.github.com/repos/dwieker/trackpy/forks","keys_url":"https://api.github.com/repos/dwieker/trackpy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dwieker/trackpy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dwieker/trackpy/teams","hooks_url":"https://api.github.com/repos/dwieker/trackpy/hooks","issue_events_url":"https://api.github.com/repos/dwieker/trackpy/issues/events{/number}","events_url":"https://api.github.com/repos/dwieker/trackpy/events","assignees_url":"https://api.github.com/repos/dwieker/trackpy/assignees{/user}","branches_url":"https://api.github.com/repos/dwieker/trackpy/branches{/branch}","tags_url":"https://api.github.com/repos/dwieker/trackpy/tags","blobs_url":"https://api.github.com/repos/dwieker/trackpy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dwieker/trackpy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dwieker/trackpy/git/refs{/sha}","trees_url":"https://api.github.com/repos/dwieker/trackpy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dwieker/trackpy/statuses/{sha}","languages_url":"https://api.github.com/repos/dwieker/trackpy/languages","stargazers_url":"https://api.github.com/repos/dwieker/trackpy/stargazers","contributors_url":"https://api.github.com/repos/dwieker/trackpy/contributors","subscribers_url":"https://api.github.com/repos/dwieker/trackpy/subscribers","subscription_url":"https://api.github.com/repos/dwieker/trackpy/subscription","commits_url":"https://api.github.com/repos/dwieker/trackpy/commits{/sha}","git_commits_url":"https://api.github.com/repos/dwieker/trackpy/git/commits{/sha}","comments_url":"https://api.github.com/repos/dwieker/trackpy/comments{/number}","issue_comment_url":"https://api.github.com/repos/dwieker/trackpy/issues/comments{/number}","contents_url":"https://api.github.com/repos/dwieker/trackpy/contents/{+path}","compare_url":"https://api.github.com/repos/dwieker/trackpy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dwieker/trackpy/merges","archive_url":"https://api.github.com/repos/dwieker/trackpy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dwieker/trackpy/downloads","issues_url":"https://api.github.com/repos/dwieker/trackpy/issues{/number}","pulls_url":"https://api.github.com/repos/dwieker/trackpy/pulls{/number}","milestones_url":"https://api.github.com/repos/dwieker/trackpy/milestones{/number}","notifications_url":"https://api.github.com/repos/dwieker/trackpy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dwieker/trackpy/labels{/name}","releases_url":"https://api.github.com/repos/dwieker/trackpy/releases{/id}","created_at":"2015-11-07T15:51:47Z","updated_at":"2015-11-07T15:51:52Z","pushed_at":"2015-11-07T16:03:20Z","git_url":"git://github.com/dwieker/trackpy.git","ssh_url":"git@github.com:dwieker/trackpy.git","clone_url":"https://github.com/dwieker/trackpy.git","svn_url":"https://github.com/dwieker/trackpy","homepage":"","size":91058,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"nkeim:master","ref":"master","sha":"7bbdd5cf125124ef18c5a2d0b3d759b3f2ad32fb","user":{"login":"nkeim","id":2985325,"avatar_url":"https://avatars.githubusercontent.com/u/2985325?v=3","gravatar_id":"","url":"https://api.github.com/users/nkeim","html_url":"https://github.com/nkeim","followers_url":"https://api.github.com/users/nkeim/followers","following_url":"https://api.github.com/users/nkeim/following{/other_user}","gists_url":"https://api.github.com/users/nkeim/gists{/gist_id}","starred_url":"https://api.github.com/users/nkeim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nkeim/subscriptions","organizations_url":"https://api.github.com/users/nkeim/orgs","repos_url":"https://api.github.com/users/nkeim/repos","events_url":"https://api.github.com/users/nkeim/events{/privacy}","received_events_url":"https://api.github.com/users/nkeim/received_events","type":"User","site_admin":false},"repo":{"id":8890908,"name":"trackpy","full_name":"nkeim/trackpy","owner":{"login":"nkeim","id":2985325,"avatar_url":"https://avatars.githubusercontent.com/u/2985325?v=3","gravatar_id":"","url":"https://api.github.com/users/nkeim","html_url":"https://github.com/nkeim","followers_url":"https://api.github.com/users/nkeim/followers","following_url":"https://api.github.com/users/nkeim/following{/other_user}","gists_url":"https://api.github.com/users/nkeim/gists{/gist_id}","starred_url":"https://api.github.com/users/nkeim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nkeim/subscriptions","organizations_url":"https://api.github.com/users/nkeim/orgs","repos_url":"https://api.github.com/users/nkeim/repos","events_url":"https://api.github.com/users/nkeim/events{/privacy}","received_events_url":"https://api.github.com/users/nkeim/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nkeim/trackpy","description":"An impure python implementation of Crocker-Grier for single particle tracking","fork":true,"url":"https://api.github.com/repos/nkeim/trackpy","forks_url":"https://api.github.com/repos/nkeim/trackpy/forks","keys_url":"https://api.github.com/repos/nkeim/trackpy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nkeim/trackpy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nkeim/trackpy/teams","hooks_url":"https://api.github.com/repos/nkeim/trackpy/hooks","issue_events_url":"https://api.github.com/repos/nkeim/trackpy/issues/events{/number}","events_url":"https://api.github.com/repos/nkeim/trackpy/events","assignees_url":"https://api.github.com/repos/nkeim/trackpy/assignees{/user}","branches_url":"https://api.github.com/repos/nkeim/trackpy/branches{/branch}","tags_url":"https://api.github.com/repos/nkeim/trackpy/tags","blobs_url":"https://api.github.com/repos/nkeim/trackpy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nkeim/trackpy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nkeim/trackpy/git/refs{/sha}","trees_url":"https://api.github.com/repos/nkeim/trackpy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nkeim/trackpy/statuses/{sha}","languages_url":"https://api.github.com/repos/nkeim/trackpy/languages","stargazers_url":"https://api.github.com/repos/nkeim/trackpy/stargazers","contributors_url":"https://api.github.com/repos/nkeim/trackpy/contributors","subscribers_url":"https://api.github.com/repos/nkeim/trackpy/subscribers","subscription_url":"https://api.github.com/repos/nkeim/trackpy/subscription","commits_url":"https://api.github.com/repos/nkeim/trackpy/commits{/sha}","git_commits_url":"https://api.github.com/repos/nkeim/trackpy/git/commits{/sha}","comments_url":"https://api.github.com/repos/nkeim/trackpy/comments{/number}","issue_comment_url":"https://api.github.com/repos/nkeim/trackpy/issues/comments{/number}","contents_url":"https://api.github.com/repos/nkeim/trackpy/contents/{+path}","compare_url":"https://api.github.com/repos/nkeim/trackpy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nkeim/trackpy/merges","archive_url":"https://api.github.com/repos/nkeim/trackpy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nkeim/trackpy/downloads","issues_url":"https://api.github.com/repos/nkeim/trackpy/issues{/number}","pulls_url":"https://api.github.com/repos/nkeim/trackpy/pulls{/number}","milestones_url":"https://api.github.com/repos/nkeim/trackpy/milestones{/number}","notifications_url":"https://api.github.com/repos/nkeim/trackpy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nkeim/trackpy/labels{/name}","releases_url":"https://api.github.com/repos/nkeim/trackpy/releases{/id}","created_at":"2013-03-19T22:28:31Z","updated_at":"2014-06-03T19:25:42Z","pushed_at":"2015-11-07T16:04:04Z","git_url":"git://github.com/nkeim/trackpy.git","ssh_url":"git@github.com:nkeim/trackpy.git","clone_url":"https://github.com/nkeim/trackpy.git","svn_url":"https://github.com/nkeim/trackpy","homepage":"","size":91726,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":3,"mirror_url":null,"open_issues_count":2,"forks":3,"open_issues":2,"watchers":1,"default_branch":"numba"}},"_links":{"self":{"href":"https://api.github.com/repos/nkeim/trackpy/pulls/4"},"html":{"href":"https://github.com/nkeim/trackpy/pull/4"},"issue":{"href":"https://api.github.com/repos/nkeim/trackpy/issues/4"},"comments":{"href":"https://api.github.com/repos/nkeim/trackpy/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/nkeim/trackpy/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/nkeim/trackpy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nkeim/trackpy/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/nkeim/trackpy/statuses/9a2bae468d99851bdb29bb00a9519991854567d1"}}}}