{"action":"created","comment":{"url":"https://api.github.com/repos/pymc-devs/pymc3/pulls/comments/81653128","pull_request_review_id":2618020,"id":81653128,"diff_hunk":"@@ -263,13 +254,36 @@ def calc_n_eff(x):\n \n     n_eff = {}\n     for var in mtrace.varnames:\n-\n-        # Get all traces for var\n         x = np.array(mtrace.get_values(var, combine=False))\n \n-        try:\n-            n_eff[var] = calc_n_eff(x)\n-        except ValueError:\n-            n_eff[var] = [calc_n_eff(y.transpose()) for y in x.transpose()]\n+        # make sure to handle scalars correctly - add extra dim if needed\n+        if len(x.shape) == 2:\n+            is_scalar = True\n+            x = np.atleast_3d(mtrace.get_values(var, combine=False))\n+        else:\n+            is_scalar = False\n+\n+        # now we are going to transpose all dims - makes the loop below\n+        # easier by moving the axes of the variable to the front instead\n+        # of the chain and sample axes\n+        x = x.transpose()\n+\n+        Vhat = get_vhat(x)\n+\n+        # get an array the same shape as the var\n+        _n_eff = np.zeros(x.shape[:-2])\n+\n+        # iterate over tuples of indices of the shape of var\n+        inds = [y.ravel().tolist() for y in np.indices(x.shape[:-2])]\n+        for tup in zip(*inds):  # iterate with zip\n+            _n_eff[tup] = get_neff(x[tup], Vhat[tup])","path":"pymc3/diagnostics.py","position":189,"original_position":189,"commit_id":"f565c6fccb4dd503f13f01146d0a6c841c0e13f6","original_commit_id":"f565c6fccb4dd503f13f01146d0a6c841c0e13f6","user":{"login":"beckermr","id":5296416,"avatar_url":"https://avatars.githubusercontent.com/u/5296416?v=3","gravatar_id":"","url":"https://api.github.com/users/beckermr","html_url":"https://github.com/beckermr","followers_url":"https://api.github.com/users/beckermr/followers","following_url":"https://api.github.com/users/beckermr/following{/other_user}","gists_url":"https://api.github.com/users/beckermr/gists{/gist_id}","starred_url":"https://api.github.com/users/beckermr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beckermr/subscriptions","organizations_url":"https://api.github.com/users/beckermr/orgs","repos_url":"https://api.github.com/users/beckermr/repos","events_url":"https://api.github.com/users/beckermr/events{/privacy}","received_events_url":"https://api.github.com/users/beckermr/received_events","type":"User","site_admin":false},"body":"This section above needs some eyes. I wrote test for the output shape, but that may not be sufficient to ensure this code is correct.","created_at":"2016-10-03T22:25:12Z","updated_at":"2016-10-03T22:25:12Z","html_url":"https://github.com/pymc-devs/pymc3/pull/1425#discussion_r81653128","pull_request_url":"https://api.github.com/repos/pymc-devs/pymc3/pulls/1425","_links":{"self":{"href":"https://api.github.com/repos/pymc-devs/pymc3/pulls/comments/81653128"},"html":{"href":"https://github.com/pymc-devs/pymc3/pull/1425#discussion_r81653128"},"pull_request":{"href":"https://api.github.com/repos/pymc-devs/pymc3/pulls/1425"}}},"pull_request":{"url":"https://api.github.com/repos/pymc-devs/pymc3/pulls/1425","id":87802821,"html_url":"https://github.com/pymc-devs/pymc3/pull/1425","diff_url":"https://github.com/pymc-devs/pymc3/pull/1425.diff","patch_url":"https://github.com/pymc-devs/pymc3/pull/1425.patch","issue_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/1425","number":1425,"state":"open","locked":false,"title":"ENH refactor diagnostics to not depend on generic ValueErrors","user":{"login":"beckermr","id":5296416,"avatar_url":"https://avatars.githubusercontent.com/u/5296416?v=3","gravatar_id":"","url":"https://api.github.com/users/beckermr","html_url":"https://github.com/beckermr","followers_url":"https://api.github.com/users/beckermr/followers","following_url":"https://api.github.com/users/beckermr/following{/other_user}","gists_url":"https://api.github.com/users/beckermr/gists{/gist_id}","starred_url":"https://api.github.com/users/beckermr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beckermr/subscriptions","organizations_url":"https://api.github.com/users/beckermr/orgs","repos_url":"https://api.github.com/users/beckermr/repos","events_url":"https://api.github.com/users/beckermr/events{/privacy}","received_events_url":"https://api.github.com/users/beckermr/received_events","type":"User","site_admin":false},"body":"I have eliminated the recursive function calls with the try except statements in the diagnostics. I had a weird thing where my debugger caught one (though I cannot reproduce that now). Furthermore, they are fragile to *actual* value errors cause by other things in the code. Finally, the control flow of the code was very difficult to follow. I added tests for some of the fancier numpy indexing. I did some PEP8-ing as well. ","created_at":"2016-10-03T22:22:16Z","updated_at":"2016-10-03T22:25:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"724f73543bd78af31e2180cb82a5d33b68df8866","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/pymc-devs/pymc3/pulls/1425/commits","review_comments_url":"https://api.github.com/repos/pymc-devs/pymc3/pulls/1425/comments","review_comment_url":"https://api.github.com/repos/pymc-devs/pymc3/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/1425/comments","statuses_url":"https://api.github.com/repos/pymc-devs/pymc3/statuses/f565c6fccb4dd503f13f01146d0a6c841c0e13f6","head":{"label":"beckermr:remove-valuerrors-diagnostics","ref":"remove-valuerrors-diagnostics","sha":"f565c6fccb4dd503f13f01146d0a6c841c0e13f6","user":{"login":"beckermr","id":5296416,"avatar_url":"https://avatars.githubusercontent.com/u/5296416?v=3","gravatar_id":"","url":"https://api.github.com/users/beckermr","html_url":"https://github.com/beckermr","followers_url":"https://api.github.com/users/beckermr/followers","following_url":"https://api.github.com/users/beckermr/following{/other_user}","gists_url":"https://api.github.com/users/beckermr/gists{/gist_id}","starred_url":"https://api.github.com/users/beckermr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beckermr/subscriptions","organizations_url":"https://api.github.com/users/beckermr/orgs","repos_url":"https://api.github.com/users/beckermr/repos","events_url":"https://api.github.com/users/beckermr/events{/privacy}","received_events_url":"https://api.github.com/users/beckermr/received_events","type":"User","site_admin":false},"repo":{"id":69900276,"name":"pymc3","full_name":"beckermr/pymc3","owner":{"login":"beckermr","id":5296416,"avatar_url":"https://avatars.githubusercontent.com/u/5296416?v=3","gravatar_id":"","url":"https://api.github.com/users/beckermr","html_url":"https://github.com/beckermr","followers_url":"https://api.github.com/users/beckermr/followers","following_url":"https://api.github.com/users/beckermr/following{/other_user}","gists_url":"https://api.github.com/users/beckermr/gists{/gist_id}","starred_url":"https://api.github.com/users/beckermr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beckermr/subscriptions","organizations_url":"https://api.github.com/users/beckermr/orgs","repos_url":"https://api.github.com/users/beckermr/repos","events_url":"https://api.github.com/users/beckermr/events{/privacy}","received_events_url":"https://api.github.com/users/beckermr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/beckermr/pymc3","description":"Probabilistic Programming in Python. Uses Theano as a backend, supports NUTS and ADVI.","fork":true,"url":"https://api.github.com/repos/beckermr/pymc3","forks_url":"https://api.github.com/repos/beckermr/pymc3/forks","keys_url":"https://api.github.com/repos/beckermr/pymc3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/beckermr/pymc3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/beckermr/pymc3/teams","hooks_url":"https://api.github.com/repos/beckermr/pymc3/hooks","issue_events_url":"https://api.github.com/repos/beckermr/pymc3/issues/events{/number}","events_url":"https://api.github.com/repos/beckermr/pymc3/events","assignees_url":"https://api.github.com/repos/beckermr/pymc3/assignees{/user}","branches_url":"https://api.github.com/repos/beckermr/pymc3/branches{/branch}","tags_url":"https://api.github.com/repos/beckermr/pymc3/tags","blobs_url":"https://api.github.com/repos/beckermr/pymc3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/beckermr/pymc3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/beckermr/pymc3/git/refs{/sha}","trees_url":"https://api.github.com/repos/beckermr/pymc3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/beckermr/pymc3/statuses/{sha}","languages_url":"https://api.github.com/repos/beckermr/pymc3/languages","stargazers_url":"https://api.github.com/repos/beckermr/pymc3/stargazers","contributors_url":"https://api.github.com/repos/beckermr/pymc3/contributors","subscribers_url":"https://api.github.com/repos/beckermr/pymc3/subscribers","subscription_url":"https://api.github.com/repos/beckermr/pymc3/subscription","commits_url":"https://api.github.com/repos/beckermr/pymc3/commits{/sha}","git_commits_url":"https://api.github.com/repos/beckermr/pymc3/git/commits{/sha}","comments_url":"https://api.github.com/repos/beckermr/pymc3/comments{/number}","issue_comment_url":"https://api.github.com/repos/beckermr/pymc3/issues/comments{/number}","contents_url":"https://api.github.com/repos/beckermr/pymc3/contents/{+path}","compare_url":"https://api.github.com/repos/beckermr/pymc3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/beckermr/pymc3/merges","archive_url":"https://api.github.com/repos/beckermr/pymc3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/beckermr/pymc3/downloads","issues_url":"https://api.github.com/repos/beckermr/pymc3/issues{/number}","pulls_url":"https://api.github.com/repos/beckermr/pymc3/pulls{/number}","milestones_url":"https://api.github.com/repos/beckermr/pymc3/milestones{/number}","notifications_url":"https://api.github.com/repos/beckermr/pymc3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/beckermr/pymc3/labels{/name}","releases_url":"https://api.github.com/repos/beckermr/pymc3/releases{/id}","deployments_url":"https://api.github.com/repos/beckermr/pymc3/deployments","created_at":"2016-10-03T18:48:21Z","updated_at":"2016-10-03T18:48:23Z","pushed_at":"2016-10-03T22:01:42Z","git_url":"git://github.com/beckermr/pymc3.git","ssh_url":"git@github.com:beckermr/pymc3.git","clone_url":"https://github.com/beckermr/pymc3.git","svn_url":"https://github.com/beckermr/pymc3","homepage":"http://pymc-devs.github.io/pymc3/","size":132651,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"pymc-devs:master","ref":"master","sha":"02ef44f197cc55fc6aafa25898819ad0828b17f4","user":{"login":"pymc-devs","id":81121,"avatar_url":"https://avatars.githubusercontent.com/u/81121?v=3","gravatar_id":"","url":"https://api.github.com/users/pymc-devs","html_url":"https://github.com/pymc-devs","followers_url":"https://api.github.com/users/pymc-devs/followers","following_url":"https://api.github.com/users/pymc-devs/following{/other_user}","gists_url":"https://api.github.com/users/pymc-devs/gists{/gist_id}","starred_url":"https://api.github.com/users/pymc-devs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pymc-devs/subscriptions","organizations_url":"https://api.github.com/users/pymc-devs/orgs","repos_url":"https://api.github.com/users/pymc-devs/repos","events_url":"https://api.github.com/users/pymc-devs/events{/privacy}","received_events_url":"https://api.github.com/users/pymc-devs/received_events","type":"Organization","site_admin":false},"repo":{"id":192904,"name":"pymc3","full_name":"pymc-devs/pymc3","owner":{"login":"pymc-devs","id":81121,"avatar_url":"https://avatars.githubusercontent.com/u/81121?v=3","gravatar_id":"","url":"https://api.github.com/users/pymc-devs","html_url":"https://github.com/pymc-devs","followers_url":"https://api.github.com/users/pymc-devs/followers","following_url":"https://api.github.com/users/pymc-devs/following{/other_user}","gists_url":"https://api.github.com/users/pymc-devs/gists{/gist_id}","starred_url":"https://api.github.com/users/pymc-devs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pymc-devs/subscriptions","organizations_url":"https://api.github.com/users/pymc-devs/orgs","repos_url":"https://api.github.com/users/pymc-devs/repos","events_url":"https://api.github.com/users/pymc-devs/events{/privacy}","received_events_url":"https://api.github.com/users/pymc-devs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pymc-devs/pymc3","description":"Probabilistic Programming in Python. Uses Theano as a backend, supports NUTS and ADVI.","fork":false,"url":"https://api.github.com/repos/pymc-devs/pymc3","forks_url":"https://api.github.com/repos/pymc-devs/pymc3/forks","keys_url":"https://api.github.com/repos/pymc-devs/pymc3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pymc-devs/pymc3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pymc-devs/pymc3/teams","hooks_url":"https://api.github.com/repos/pymc-devs/pymc3/hooks","issue_events_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/events{/number}","events_url":"https://api.github.com/repos/pymc-devs/pymc3/events","assignees_url":"https://api.github.com/repos/pymc-devs/pymc3/assignees{/user}","branches_url":"https://api.github.com/repos/pymc-devs/pymc3/branches{/branch}","tags_url":"https://api.github.com/repos/pymc-devs/pymc3/tags","blobs_url":"https://api.github.com/repos/pymc-devs/pymc3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pymc-devs/pymc3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pymc-devs/pymc3/git/refs{/sha}","trees_url":"https://api.github.com/repos/pymc-devs/pymc3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pymc-devs/pymc3/statuses/{sha}","languages_url":"https://api.github.com/repos/pymc-devs/pymc3/languages","stargazers_url":"https://api.github.com/repos/pymc-devs/pymc3/stargazers","contributors_url":"https://api.github.com/repos/pymc-devs/pymc3/contributors","subscribers_url":"https://api.github.com/repos/pymc-devs/pymc3/subscribers","subscription_url":"https://api.github.com/repos/pymc-devs/pymc3/subscription","commits_url":"https://api.github.com/repos/pymc-devs/pymc3/commits{/sha}","git_commits_url":"https://api.github.com/repos/pymc-devs/pymc3/git/commits{/sha}","comments_url":"https://api.github.com/repos/pymc-devs/pymc3/comments{/number}","issue_comment_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/comments{/number}","contents_url":"https://api.github.com/repos/pymc-devs/pymc3/contents/{+path}","compare_url":"https://api.github.com/repos/pymc-devs/pymc3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pymc-devs/pymc3/merges","archive_url":"https://api.github.com/repos/pymc-devs/pymc3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pymc-devs/pymc3/downloads","issues_url":"https://api.github.com/repos/pymc-devs/pymc3/issues{/number}","pulls_url":"https://api.github.com/repos/pymc-devs/pymc3/pulls{/number}","milestones_url":"https://api.github.com/repos/pymc-devs/pymc3/milestones{/number}","notifications_url":"https://api.github.com/repos/pymc-devs/pymc3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pymc-devs/pymc3/labels{/name}","releases_url":"https://api.github.com/repos/pymc-devs/pymc3/releases{/id}","deployments_url":"https://api.github.com/repos/pymc-devs/pymc3/deployments","created_at":"2009-05-05T09:43:50Z","updated_at":"2016-09-30T14:47:52Z","pushed_at":"2016-10-03T22:23:28Z","git_url":"git://github.com/pymc-devs/pymc3.git","ssh_url":"git@github.com:pymc-devs/pymc3.git","clone_url":"https://github.com/pymc-devs/pymc3.git","svn_url":"https://github.com/pymc-devs/pymc3","homepage":"http://pymc-devs.github.io/pymc3/","size":131920,"stargazers_count":1652,"watchers_count":1652,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":396,"mirror_url":null,"open_issues_count":127,"forks":396,"open_issues":127,"watchers":1652,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pymc-devs/pymc3/pulls/1425"},"html":{"href":"https://github.com/pymc-devs/pymc3/pull/1425"},"issue":{"href":"https://api.github.com/repos/pymc-devs/pymc3/issues/1425"},"comments":{"href":"https://api.github.com/repos/pymc-devs/pymc3/issues/1425/comments"},"review_comments":{"href":"https://api.github.com/repos/pymc-devs/pymc3/pulls/1425/comments"},"review_comment":{"href":"https://api.github.com/repos/pymc-devs/pymc3/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pymc-devs/pymc3/pulls/1425/commits"},"statuses":{"href":"https://api.github.com/repos/pymc-devs/pymc3/statuses/f565c6fccb4dd503f13f01146d0a6c841c0e13f6"}}}}
{"actor":{"display_login":"beckermr"}}