{"action":"created","comment":{"url":"https://api.github.com/repos/TuringLang/Turing.jl/pulls/comments/197423598","pull_request_review_id":131166016,"id":197423598,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5NzQyMzU5OA==","diff_hunk":"@@ -75,18 +108,52 @@ end\n \n # Compute Hamiltonian\n find_H(p::Vector, model::Function, vi::VarInfo, spl::Sampler) = begin\n-  # NOTE: getlogp(vi) = 0 means the current vals[end] hasn't been used at all.\n-  #       This can be a result of link/invlink (where expand! is used)\n-  if getlogp(vi) == 0 vi = runmodel(model, vi, spl) end\n \n-  p_orig = p .* spl.info[:wum][:stds]\n+  # Old code\n+  # # NOTE: getlogp(vi) = 0 means the current vals[end] hasn't been used at all.\n+  # #       This can be a result of link/invlink (where expand! is used)\n+  # if getlogp(vi) == 0 vi = runmodel(model, vi, spl) end\n+  #\n+  # p_orig = p .* spl.info[:wum][:stds]\n+  #\n+  # H = dot(p_orig, p_orig) / 2 + realpart(-getlogp(vi))\n+  # if isnan(H) H = Inf else H end\n+  #\n+  # H\n+\n+  logpdf_func_float(theta) = begin\n \n-  H = dot(p_orig, p_orig) / 2 + realpart(-getlogp(vi))\n-  if isnan(H) H = Inf else H end\n+      vi[spl][:] = theta[:]\n+      realpart(runmodel(model, vi, spl).logp)\n+\n+  end\n+\n+  return _find_H(vi[spl], p, logpdf_func_float, spl.info[:wum][:stds])\n+\n+end\n+\n+function _find_H(theta::T, p::Vector, logpdf_func_float::Function, stds::Vector) where {T<:Union{Vector,SubArray}}\n+\n+  lp = logpdf_func_float(theta)\n+\n+  return _find_H(theta, p, lp, stds)\n \n-  H\n end\n \n+function _find_H(theta::T, p::Vector, lp::Real, stds::Vector) where {T<:Union{Vector,SubArray}}\n+\n+  p_orig = p .* stds\n+\n+  H = 0.5 * dot(p_orig, p_orig) + (-lp)\n+\n+  H = isnan(H) ? Inf : H","path":"src/samplers/support/hmc_core.jl","position":242,"original_position":175,"commit_id":"26e72fbe492be96689f5e40c4e4e37372f337f44","original_commit_id":"79222f80bc92a1364649ca119e036481e23bcc87","user":{"login":"wesselb","id":1444448,"node_id":"MDQ6VXNlcjE0NDQ0NDg=","avatar_url":"https://avatars3.githubusercontent.com/u/1444448?v=4","gravatar_id":"","url":"https://api.github.com/users/wesselb","html_url":"https://github.com/wesselb","followers_url":"https://api.github.com/users/wesselb/followers","following_url":"https://api.github.com/users/wesselb/following{/other_user}","gists_url":"https://api.github.com/users/wesselb/gists{/gist_id}","starred_url":"https://api.github.com/users/wesselb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wesselb/subscriptions","organizations_url":"https://api.github.com/users/wesselb/orgs","repos_url":"https://api.github.com/users/wesselb/repos","events_url":"https://api.github.com/users/wesselb/events{/privacy}","received_events_url":"https://api.github.com/users/wesselb/received_events","type":"User","site_admin":false},"body":"That makes sense. Thanks for the clarification, @xukai92! ","created_at":"2018-06-22T11:53:28Z","updated_at":"2018-06-22T11:53:28Z","html_url":"https://github.com/TuringLang/Turing.jl/pull/436#discussion_r197423598","pull_request_url":"https://api.github.com/repos/TuringLang/Turing.jl/pulls/436","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/TuringLang/Turing.jl/pulls/comments/197423598"},"html":{"href":"https://github.com/TuringLang/Turing.jl/pull/436#discussion_r197423598"},"pull_request":{"href":"https://api.github.com/repos/TuringLang/Turing.jl/pulls/436"}},"in_reply_to_id":197172294},"pull_request":{"url":"https://api.github.com/repos/TuringLang/Turing.jl/pulls/436","id":182018427,"node_id":"MDExOlB1bGxSZXF1ZXN0MTgyMDE4NDI3","html_url":"https://github.com/TuringLang/Turing.jl/pull/436","diff_url":"https://github.com/TuringLang/Turing.jl/pull/436.diff","patch_url":"https://github.com/TuringLang/Turing.jl/pull/436.patch","issue_url":"https://api.github.com/repos/TuringLang/Turing.jl/issues/436","number":436,"state":"open","locked":false,"title":"Refactoring HMC API","user":{"login":"xukai92","id":5985769,"node_id":"MDQ6VXNlcjU5ODU3Njk=","avatar_url":"https://avatars1.githubusercontent.com/u/5985769?v=4","gravatar_id":"","url":"https://api.github.com/users/xukai92","html_url":"https://github.com/xukai92","followers_url":"https://api.github.com/users/xukai92/followers","following_url":"https://api.github.com/users/xukai92/following{/other_user}","gists_url":"https://api.github.com/users/xukai92/gists{/gist_id}","starred_url":"https://api.github.com/users/xukai92/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xukai92/subscriptions","organizations_url":"https://api.github.com/users/xukai92/orgs","repos_url":"https://api.github.com/users/xukai92/repos","events_url":"https://api.github.com/users/xukai92/events{/privacy}","received_events_url":"https://api.github.com/users/xukai92/received_events","type":"User","site_admin":false},"body":"Addressing https://github.com/yebai/Turing.jl/issues/431\r\n\r\nStill in working.","created_at":"2018-04-16T23:58:23Z","updated_at":"2018-06-22T11:53:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dcd6c1eabab2d22cb0105c68f800662daf493d16","assignee":null,"assignees":[],"requested_reviewers":[{"login":"yebai","id":3279477,"node_id":"MDQ6VXNlcjMyNzk0Nzc=","avatar_url":"https://avatars2.githubusercontent.com/u/3279477?v=4","gravatar_id":"","url":"https://api.github.com/users/yebai","html_url":"https://github.com/yebai","followers_url":"https://api.github.com/users/yebai/followers","following_url":"https://api.github.com/users/yebai/following{/other_user}","gists_url":"https://api.github.com/users/yebai/gists{/gist_id}","starred_url":"https://api.github.com/users/yebai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yebai/subscriptions","organizations_url":"https://api.github.com/users/yebai/orgs","repos_url":"https://api.github.com/users/yebai/repos","events_url":"https://api.github.com/users/yebai/events{/privacy}","received_events_url":"https://api.github.com/users/yebai/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/TuringLang/Turing.jl/pulls/436/commits","review_comments_url":"https://api.github.com/repos/TuringLang/Turing.jl/pulls/436/comments","review_comment_url":"https://api.github.com/repos/TuringLang/Turing.jl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/TuringLang/Turing.jl/issues/436/comments","statuses_url":"https://api.github.com/repos/TuringLang/Turing.jl/statuses/26e72fbe492be96689f5e40c4e4e37372f337f44","head":{"label":"TuringLang:refactor-hmc-api","ref":"refactor-hmc-api","sha":"26e72fbe492be96689f5e40c4e4e37372f337f44","user":{"login":"TuringLang","id":26261527,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI2MjYxNTI3","avatar_url":"https://avatars1.githubusercontent.com/u/26261527?v=4","gravatar_id":"","url":"https://api.github.com/users/TuringLang","html_url":"https://github.com/TuringLang","followers_url":"https://api.github.com/users/TuringLang/followers","following_url":"https://api.github.com/users/TuringLang/following{/other_user}","gists_url":"https://api.github.com/users/TuringLang/gists{/gist_id}","starred_url":"https://api.github.com/users/TuringLang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TuringLang/subscriptions","organizations_url":"https://api.github.com/users/TuringLang/orgs","repos_url":"https://api.github.com/users/TuringLang/repos","events_url":"https://api.github.com/users/TuringLang/events{/privacy}","received_events_url":"https://api.github.com/users/TuringLang/received_events","type":"Organization","site_admin":false},"repo":{"id":57377821,"node_id":"MDEwOlJlcG9zaXRvcnk1NzM3NzgyMQ==","name":"Turing.jl","full_name":"TuringLang/Turing.jl","owner":{"login":"TuringLang","id":26261527,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI2MjYxNTI3","avatar_url":"https://avatars1.githubusercontent.com/u/26261527?v=4","gravatar_id":"","url":"https://api.github.com/users/TuringLang","html_url":"https://github.com/TuringLang","followers_url":"https://api.github.com/users/TuringLang/followers","following_url":"https://api.github.com/users/TuringLang/following{/other_user}","gists_url":"https://api.github.com/users/TuringLang/gists{/gist_id}","starred_url":"https://api.github.com/users/TuringLang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TuringLang/subscriptions","organizations_url":"https://api.github.com/users/TuringLang/orgs","repos_url":"https://api.github.com/users/TuringLang/repos","events_url":"https://api.github.com/users/TuringLang/events{/privacy}","received_events_url":"https://api.github.com/users/TuringLang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/TuringLang/Turing.jl","description":"The Turing language for probabilistic programming","fork":false,"url":"https://api.github.com/repos/TuringLang/Turing.jl","forks_url":"https://api.github.com/repos/TuringLang/Turing.jl/forks","keys_url":"https://api.github.com/repos/TuringLang/Turing.jl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TuringLang/Turing.jl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TuringLang/Turing.jl/teams","hooks_url":"https://api.github.com/repos/TuringLang/Turing.jl/hooks","issue_events_url":"https://api.github.com/repos/TuringLang/Turing.jl/issues/events{/number}","events_url":"https://api.github.com/repos/TuringLang/Turing.jl/events","assignees_url":"https://api.github.com/repos/TuringLang/Turing.jl/assignees{/user}","branches_url":"https://api.github.com/repos/TuringLang/Turing.jl/branches{/branch}","tags_url":"https://api.github.com/repos/TuringLang/Turing.jl/tags","blobs_url":"https://api.github.com/repos/TuringLang/Turing.jl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TuringLang/Turing.jl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TuringLang/Turing.jl/git/refs{/sha}","trees_url":"https://api.github.com/repos/TuringLang/Turing.jl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TuringLang/Turing.jl/statuses/{sha}","languages_url":"https://api.github.com/repos/TuringLang/Turing.jl/languages","stargazers_url":"https://api.github.com/repos/TuringLang/Turing.jl/stargazers","contributors_url":"https://api.github.com/repos/TuringLang/Turing.jl/contributors","subscribers_url":"https://api.github.com/repos/TuringLang/Turing.jl/subscribers","subscription_url":"https://api.github.com/repos/TuringLang/Turing.jl/subscription","commits_url":"https://api.github.com/repos/TuringLang/Turing.jl/commits{/sha}","git_commits_url":"https://api.github.com/repos/TuringLang/Turing.jl/git/commits{/sha}","comments_url":"https://api.github.com/repos/TuringLang/Turing.jl/comments{/number}","issue_comment_url":"https://api.github.com/repos/TuringLang/Turing.jl/issues/comments{/number}","contents_url":"https://api.github.com/repos/TuringLang/Turing.jl/contents/{+path}","compare_url":"https://api.github.com/repos/TuringLang/Turing.jl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TuringLang/Turing.jl/merges","archive_url":"https://api.github.com/repos/TuringLang/Turing.jl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TuringLang/Turing.jl/downloads","issues_url":"https://api.github.com/repos/TuringLang/Turing.jl/issues{/number}","pulls_url":"https://api.github.com/repos/TuringLang/Turing.jl/pulls{/number}","milestones_url":"https://api.github.com/repos/TuringLang/Turing.jl/milestones{/number}","notifications_url":"https://api.github.com/repos/TuringLang/Turing.jl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TuringLang/Turing.jl/labels{/name}","releases_url":"https://api.github.com/repos/TuringLang/Turing.jl/releases{/id}","deployments_url":"https://api.github.com/repos/TuringLang/Turing.jl/deployments","created_at":"2016-04-29T10:51:43Z","updated_at":"2018-06-22T09:42:59Z","pushed_at":"2018-06-21T23:07:27Z","git_url":"git://github.com/TuringLang/Turing.jl.git","ssh_url":"git@github.com:TuringLang/Turing.jl.git","clone_url":"https://github.com/TuringLang/Turing.jl.git","svn_url":"https://github.com/TuringLang/Turing.jl","homepage":"http://turing.ml","size":14866,"stargazers_count":238,"watchers_count":238,"language":"Julia","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":29,"mirror_url":null,"archived":false,"open_issues_count":81,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":29,"open_issues":81,"watchers":238,"default_branch":"master"}},"base":{"label":"TuringLang:master","ref":"master","sha":"f803bbb298f57275ff2649f579b73c34eed61528","user":{"login":"TuringLang","id":26261527,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI2MjYxNTI3","avatar_url":"https://avatars1.githubusercontent.com/u/26261527?v=4","gravatar_id":"","url":"https://api.github.com/users/TuringLang","html_url":"https://github.com/TuringLang","followers_url":"https://api.github.com/users/TuringLang/followers","following_url":"https://api.github.com/users/TuringLang/following{/other_user}","gists_url":"https://api.github.com/users/TuringLang/gists{/gist_id}","starred_url":"https://api.github.com/users/TuringLang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TuringLang/subscriptions","organizations_url":"https://api.github.com/users/TuringLang/orgs","repos_url":"https://api.github.com/users/TuringLang/repos","events_url":"https://api.github.com/users/TuringLang/events{/privacy}","received_events_url":"https://api.github.com/users/TuringLang/received_events","type":"Organization","site_admin":false},"repo":{"id":57377821,"node_id":"MDEwOlJlcG9zaXRvcnk1NzM3NzgyMQ==","name":"Turing.jl","full_name":"TuringLang/Turing.jl","owner":{"login":"TuringLang","id":26261527,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI2MjYxNTI3","avatar_url":"https://avatars1.githubusercontent.com/u/26261527?v=4","gravatar_id":"","url":"https://api.github.com/users/TuringLang","html_url":"https://github.com/TuringLang","followers_url":"https://api.github.com/users/TuringLang/followers","following_url":"https://api.github.com/users/TuringLang/following{/other_user}","gists_url":"https://api.github.com/users/TuringLang/gists{/gist_id}","starred_url":"https://api.github.com/users/TuringLang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TuringLang/subscriptions","organizations_url":"https://api.github.com/users/TuringLang/orgs","repos_url":"https://api.github.com/users/TuringLang/repos","events_url":"https://api.github.com/users/TuringLang/events{/privacy}","received_events_url":"https://api.github.com/users/TuringLang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/TuringLang/Turing.jl","description":"The Turing language for probabilistic programming","fork":false,"url":"https://api.github.com/repos/TuringLang/Turing.jl","forks_url":"https://api.github.com/repos/TuringLang/Turing.jl/forks","keys_url":"https://api.github.com/repos/TuringLang/Turing.jl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TuringLang/Turing.jl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TuringLang/Turing.jl/teams","hooks_url":"https://api.github.com/repos/TuringLang/Turing.jl/hooks","issue_events_url":"https://api.github.com/repos/TuringLang/Turing.jl/issues/events{/number}","events_url":"https://api.github.com/repos/TuringLang/Turing.jl/events","assignees_url":"https://api.github.com/repos/TuringLang/Turing.jl/assignees{/user}","branches_url":"https://api.github.com/repos/TuringLang/Turing.jl/branches{/branch}","tags_url":"https://api.github.com/repos/TuringLang/Turing.jl/tags","blobs_url":"https://api.github.com/repos/TuringLang/Turing.jl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TuringLang/Turing.jl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TuringLang/Turing.jl/git/refs{/sha}","trees_url":"https://api.github.com/repos/TuringLang/Turing.jl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TuringLang/Turing.jl/statuses/{sha}","languages_url":"https://api.github.com/repos/TuringLang/Turing.jl/languages","stargazers_url":"https://api.github.com/repos/TuringLang/Turing.jl/stargazers","contributors_url":"https://api.github.com/repos/TuringLang/Turing.jl/contributors","subscribers_url":"https://api.github.com/repos/TuringLang/Turing.jl/subscribers","subscription_url":"https://api.github.com/repos/TuringLang/Turing.jl/subscription","commits_url":"https://api.github.com/repos/TuringLang/Turing.jl/commits{/sha}","git_commits_url":"https://api.github.com/repos/TuringLang/Turing.jl/git/commits{/sha}","comments_url":"https://api.github.com/repos/TuringLang/Turing.jl/comments{/number}","issue_comment_url":"https://api.github.com/repos/TuringLang/Turing.jl/issues/comments{/number}","contents_url":"https://api.github.com/repos/TuringLang/Turing.jl/contents/{+path}","compare_url":"https://api.github.com/repos/TuringLang/Turing.jl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TuringLang/Turing.jl/merges","archive_url":"https://api.github.com/repos/TuringLang/Turing.jl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TuringLang/Turing.jl/downloads","issues_url":"https://api.github.com/repos/TuringLang/Turing.jl/issues{/number}","pulls_url":"https://api.github.com/repos/TuringLang/Turing.jl/pulls{/number}","milestones_url":"https://api.github.com/repos/TuringLang/Turing.jl/milestones{/number}","notifications_url":"https://api.github.com/repos/TuringLang/Turing.jl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TuringLang/Turing.jl/labels{/name}","releases_url":"https://api.github.com/repos/TuringLang/Turing.jl/releases{/id}","deployments_url":"https://api.github.com/repos/TuringLang/Turing.jl/deployments","created_at":"2016-04-29T10:51:43Z","updated_at":"2018-06-22T09:42:59Z","pushed_at":"2018-06-21T23:07:27Z","git_url":"git://github.com/TuringLang/Turing.jl.git","ssh_url":"git@github.com:TuringLang/Turing.jl.git","clone_url":"https://github.com/TuringLang/Turing.jl.git","svn_url":"https://github.com/TuringLang/Turing.jl","homepage":"http://turing.ml","size":14866,"stargazers_count":238,"watchers_count":238,"language":"Julia","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":29,"mirror_url":null,"archived":false,"open_issues_count":81,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":29,"open_issues":81,"watchers":238,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/TuringLang/Turing.jl/pulls/436"},"html":{"href":"https://github.com/TuringLang/Turing.jl/pull/436"},"issue":{"href":"https://api.github.com/repos/TuringLang/Turing.jl/issues/436"},"comments":{"href":"https://api.github.com/repos/TuringLang/Turing.jl/issues/436/comments"},"review_comments":{"href":"https://api.github.com/repos/TuringLang/Turing.jl/pulls/436/comments"},"review_comment":{"href":"https://api.github.com/repos/TuringLang/Turing.jl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/TuringLang/Turing.jl/pulls/436/commits"},"statuses":{"href":"https://api.github.com/repos/TuringLang/Turing.jl/statuses/26e72fbe492be96689f5e40c4e4e37372f337f44"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"wesselb"}}