{"action":"created","comment":{"url":"https://api.github.com/repos/pgmpy/pgmpy/pulls/comments/25330445","id":25330445,"diff_hunk":"@@ -191,39 +191,26 @@ def marginalize(self, variables, inplace=True):\n             factor = self\n         else:\n             factor = Factor(self.scope(), self.cardinality, self.values)\n-\n+        marginalize_index = np.array(np.where(np.in1d(factor.scope(),variables)))\n+        assign = np.array(factor.cardinality)\n+        assign[marginalize_index] = -1\n+        sum_variable = np.zeros(len(factor.cardinality))\n+        sum_variable[marginalize_index] = -1\n+        marg_factor = []\n+        for i in itertools.product(*[range(index) for index in factor.cardinality[np.where(assign!=-1)[0]]]):\n+            temp_sum = 0\n+            sum_variable[sum_variable!=-1] = i\n+            for index in factor._index_for_assignment(sum_variable):\n+                temp_sum += factor.values[index]","path":"pgmpy/factors/Factor.py","position":null,"original_position":24,"commit_id":"029dc2f2d8fa6fc5cb63e6c019b4744506c5e5d5","original_commit_id":"22ecccc7be33a179ab666b16c4b7133e054bc2f7","user":{"login":"palashahuja","id":8504351,"avatar_url":"https://avatars.githubusercontent.com/u/8504351?v=3","gravatar_id":"","url":"https://api.github.com/users/palashahuja","html_url":"https://github.com/palashahuja","followers_url":"https://api.github.com/users/palashahuja/followers","following_url":"https://api.github.com/users/palashahuja/following{/other_user}","gists_url":"https://api.github.com/users/palashahuja/gists{/gist_id}","starred_url":"https://api.github.com/users/palashahuja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palashahuja/subscriptions","organizations_url":"https://api.github.com/users/palashahuja/orgs","repos_url":"https://api.github.com/users/palashahuja/repos","events_url":"https://api.github.com/users/palashahuja/events{/privacy}","received_events_url":"https://api.github.com/users/palashahuja/received_events","type":"User","site_admin":false},"body":"Yes , we can . I will make the changes now. \r\n","created_at":"2015-02-25T10:33:44Z","updated_at":"2015-02-25T10:33:44Z","html_url":"https://github.com/pgmpy/pgmpy/pull/282#discussion_r25330445","pull_request_url":"https://api.github.com/repos/pgmpy/pgmpy/pulls/282","_links":{"self":{"href":"https://api.github.com/repos/pgmpy/pgmpy/pulls/comments/25330445"},"html":{"href":"https://github.com/pgmpy/pgmpy/pull/282#discussion_r25330445"},"pull_request":{"href":"https://api.github.com/repos/pgmpy/pgmpy/pulls/282"}}},"pull_request":{"url":"https://api.github.com/repos/pgmpy/pgmpy/pulls/282","id":29370834,"html_url":"https://github.com/pgmpy/pgmpy/pull/282","diff_url":"https://github.com/pgmpy/pgmpy/pull/282.diff","patch_url":"https://github.com/pgmpy/pgmpy/pull/282.patch","issue_url":"https://api.github.com/repos/pgmpy/pgmpy/issues/282","number":282,"state":"open","locked":false,"title":"Faster implementation of marginalize . bug #267","user":{"login":"palashahuja","id":8504351,"avatar_url":"https://avatars.githubusercontent.com/u/8504351?v=3","gravatar_id":"","url":"https://api.github.com/users/palashahuja","html_url":"https://github.com/palashahuja","followers_url":"https://api.github.com/users/palashahuja/followers","following_url":"https://api.github.com/users/palashahuja/following{/other_user}","gists_url":"https://api.github.com/users/palashahuja/gists{/gist_id}","starred_url":"https://api.github.com/users/palashahuja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palashahuja/subscriptions","organizations_url":"https://api.github.com/users/palashahuja/orgs","repos_url":"https://api.github.com/users/palashahuja/repos","events_url":"https://api.github.com/users/palashahuja/events{/privacy}","received_events_url":"https://api.github.com/users/palashahuja/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-02-16T12:54:39Z","updated_at":"2015-02-25T10:33:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d2258b71184c6d1f13994d687dce17ac06107aaa","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pgmpy/pgmpy/pulls/282/commits","review_comments_url":"https://api.github.com/repos/pgmpy/pgmpy/pulls/282/comments","review_comment_url":"https://api.github.com/repos/pgmpy/pgmpy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pgmpy/pgmpy/issues/282/comments","statuses_url":"https://api.github.com/repos/pgmpy/pgmpy/statuses/029dc2f2d8fa6fc5cb63e6c019b4744506c5e5d5","head":{"label":"palashahuja:patch-2","ref":"patch-2","sha":"029dc2f2d8fa6fc5cb63e6c019b4744506c5e5d5","user":{"login":"palashahuja","id":8504351,"avatar_url":"https://avatars.githubusercontent.com/u/8504351?v=3","gravatar_id":"","url":"https://api.github.com/users/palashahuja","html_url":"https://github.com/palashahuja","followers_url":"https://api.github.com/users/palashahuja/followers","following_url":"https://api.github.com/users/palashahuja/following{/other_user}","gists_url":"https://api.github.com/users/palashahuja/gists{/gist_id}","starred_url":"https://api.github.com/users/palashahuja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palashahuja/subscriptions","organizations_url":"https://api.github.com/users/palashahuja/orgs","repos_url":"https://api.github.com/users/palashahuja/repos","events_url":"https://api.github.com/users/palashahuja/events{/privacy}","received_events_url":"https://api.github.com/users/palashahuja/received_events","type":"User","site_admin":false},"repo":{"id":27803389,"name":"pgmpy","full_name":"palashahuja/pgmpy","owner":{"login":"palashahuja","id":8504351,"avatar_url":"https://avatars.githubusercontent.com/u/8504351?v=3","gravatar_id":"","url":"https://api.github.com/users/palashahuja","html_url":"https://github.com/palashahuja","followers_url":"https://api.github.com/users/palashahuja/followers","following_url":"https://api.github.com/users/palashahuja/following{/other_user}","gists_url":"https://api.github.com/users/palashahuja/gists{/gist_id}","starred_url":"https://api.github.com/users/palashahuja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palashahuja/subscriptions","organizations_url":"https://api.github.com/users/palashahuja/orgs","repos_url":"https://api.github.com/users/palashahuja/repos","events_url":"https://api.github.com/users/palashahuja/events{/privacy}","received_events_url":"https://api.github.com/users/palashahuja/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/palashahuja/pgmpy","description":"Python Library for Probabilistic Graphical Models","fork":true,"url":"https://api.github.com/repos/palashahuja/pgmpy","forks_url":"https://api.github.com/repos/palashahuja/pgmpy/forks","keys_url":"https://api.github.com/repos/palashahuja/pgmpy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/palashahuja/pgmpy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/palashahuja/pgmpy/teams","hooks_url":"https://api.github.com/repos/palashahuja/pgmpy/hooks","issue_events_url":"https://api.github.com/repos/palashahuja/pgmpy/issues/events{/number}","events_url":"https://api.github.com/repos/palashahuja/pgmpy/events","assignees_url":"https://api.github.com/repos/palashahuja/pgmpy/assignees{/user}","branches_url":"https://api.github.com/repos/palashahuja/pgmpy/branches{/branch}","tags_url":"https://api.github.com/repos/palashahuja/pgmpy/tags","blobs_url":"https://api.github.com/repos/palashahuja/pgmpy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/palashahuja/pgmpy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/palashahuja/pgmpy/git/refs{/sha}","trees_url":"https://api.github.com/repos/palashahuja/pgmpy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/palashahuja/pgmpy/statuses/{sha}","languages_url":"https://api.github.com/repos/palashahuja/pgmpy/languages","stargazers_url":"https://api.github.com/repos/palashahuja/pgmpy/stargazers","contributors_url":"https://api.github.com/repos/palashahuja/pgmpy/contributors","subscribers_url":"https://api.github.com/repos/palashahuja/pgmpy/subscribers","subscription_url":"https://api.github.com/repos/palashahuja/pgmpy/subscription","commits_url":"https://api.github.com/repos/palashahuja/pgmpy/commits{/sha}","git_commits_url":"https://api.github.com/repos/palashahuja/pgmpy/git/commits{/sha}","comments_url":"https://api.github.com/repos/palashahuja/pgmpy/comments{/number}","issue_comment_url":"https://api.github.com/repos/palashahuja/pgmpy/issues/comments{/number}","contents_url":"https://api.github.com/repos/palashahuja/pgmpy/contents/{+path}","compare_url":"https://api.github.com/repos/palashahuja/pgmpy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/palashahuja/pgmpy/merges","archive_url":"https://api.github.com/repos/palashahuja/pgmpy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/palashahuja/pgmpy/downloads","issues_url":"https://api.github.com/repos/palashahuja/pgmpy/issues{/number}","pulls_url":"https://api.github.com/repos/palashahuja/pgmpy/pulls{/number}","milestones_url":"https://api.github.com/repos/palashahuja/pgmpy/milestones{/number}","notifications_url":"https://api.github.com/repos/palashahuja/pgmpy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/palashahuja/pgmpy/labels{/name}","releases_url":"https://api.github.com/repos/palashahuja/pgmpy/releases{/id}","created_at":"2014-12-10T05:11:15Z","updated_at":"2014-12-10T05:11:16Z","pushed_at":"2015-02-25T09:23:54Z","git_url":"git://github.com/palashahuja/pgmpy.git","ssh_url":"git@github.com:palashahuja/pgmpy.git","clone_url":"https://github.com/palashahuja/pgmpy.git","svn_url":"https://github.com/palashahuja/pgmpy","homepage":null,"size":3943,"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":"dev"}},"base":{"label":"pgmpy:dev","ref":"dev","sha":"e11ea2a0e79175ac35276d0963fcbcc09287d321","user":{"login":"pgmpy","id":5500131,"avatar_url":"https://avatars.githubusercontent.com/u/5500131?v=3","gravatar_id":"","url":"https://api.github.com/users/pgmpy","html_url":"https://github.com/pgmpy","followers_url":"https://api.github.com/users/pgmpy/followers","following_url":"https://api.github.com/users/pgmpy/following{/other_user}","gists_url":"https://api.github.com/users/pgmpy/gists{/gist_id}","starred_url":"https://api.github.com/users/pgmpy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pgmpy/subscriptions","organizations_url":"https://api.github.com/users/pgmpy/orgs","repos_url":"https://api.github.com/users/pgmpy/repos","events_url":"https://api.github.com/users/pgmpy/events{/privacy}","received_events_url":"https://api.github.com/users/pgmpy/received_events","type":"Organization","site_admin":false},"repo":{"id":12968651,"name":"pgmpy","full_name":"pgmpy/pgmpy","owner":{"login":"pgmpy","id":5500131,"avatar_url":"https://avatars.githubusercontent.com/u/5500131?v=3","gravatar_id":"","url":"https://api.github.com/users/pgmpy","html_url":"https://github.com/pgmpy","followers_url":"https://api.github.com/users/pgmpy/followers","following_url":"https://api.github.com/users/pgmpy/following{/other_user}","gists_url":"https://api.github.com/users/pgmpy/gists{/gist_id}","starred_url":"https://api.github.com/users/pgmpy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pgmpy/subscriptions","organizations_url":"https://api.github.com/users/pgmpy/orgs","repos_url":"https://api.github.com/users/pgmpy/repos","events_url":"https://api.github.com/users/pgmpy/events{/privacy}","received_events_url":"https://api.github.com/users/pgmpy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pgmpy/pgmpy","description":"Python Library for Probabilistic Graphical Models","fork":false,"url":"https://api.github.com/repos/pgmpy/pgmpy","forks_url":"https://api.github.com/repos/pgmpy/pgmpy/forks","keys_url":"https://api.github.com/repos/pgmpy/pgmpy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pgmpy/pgmpy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pgmpy/pgmpy/teams","hooks_url":"https://api.github.com/repos/pgmpy/pgmpy/hooks","issue_events_url":"https://api.github.com/repos/pgmpy/pgmpy/issues/events{/number}","events_url":"https://api.github.com/repos/pgmpy/pgmpy/events","assignees_url":"https://api.github.com/repos/pgmpy/pgmpy/assignees{/user}","branches_url":"https://api.github.com/repos/pgmpy/pgmpy/branches{/branch}","tags_url":"https://api.github.com/repos/pgmpy/pgmpy/tags","blobs_url":"https://api.github.com/repos/pgmpy/pgmpy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pgmpy/pgmpy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pgmpy/pgmpy/git/refs{/sha}","trees_url":"https://api.github.com/repos/pgmpy/pgmpy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pgmpy/pgmpy/statuses/{sha}","languages_url":"https://api.github.com/repos/pgmpy/pgmpy/languages","stargazers_url":"https://api.github.com/repos/pgmpy/pgmpy/stargazers","contributors_url":"https://api.github.com/repos/pgmpy/pgmpy/contributors","subscribers_url":"https://api.github.com/repos/pgmpy/pgmpy/subscribers","subscription_url":"https://api.github.com/repos/pgmpy/pgmpy/subscription","commits_url":"https://api.github.com/repos/pgmpy/pgmpy/commits{/sha}","git_commits_url":"https://api.github.com/repos/pgmpy/pgmpy/git/commits{/sha}","comments_url":"https://api.github.com/repos/pgmpy/pgmpy/comments{/number}","issue_comment_url":"https://api.github.com/repos/pgmpy/pgmpy/issues/comments{/number}","contents_url":"https://api.github.com/repos/pgmpy/pgmpy/contents/{+path}","compare_url":"https://api.github.com/repos/pgmpy/pgmpy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pgmpy/pgmpy/merges","archive_url":"https://api.github.com/repos/pgmpy/pgmpy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pgmpy/pgmpy/downloads","issues_url":"https://api.github.com/repos/pgmpy/pgmpy/issues{/number}","pulls_url":"https://api.github.com/repos/pgmpy/pgmpy/pulls{/number}","milestones_url":"https://api.github.com/repos/pgmpy/pgmpy/milestones{/number}","notifications_url":"https://api.github.com/repos/pgmpy/pgmpy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pgmpy/pgmpy/labels{/name}","releases_url":"https://api.github.com/repos/pgmpy/pgmpy/releases{/id}","created_at":"2013-09-20T08:18:58Z","updated_at":"2015-02-22T09:13:37Z","pushed_at":"2015-02-14T15:12:40Z","git_url":"git://github.com/pgmpy/pgmpy.git","ssh_url":"git@github.com:pgmpy/pgmpy.git","clone_url":"https://github.com/pgmpy/pgmpy.git","svn_url":"https://github.com/pgmpy/pgmpy","homepage":null,"size":5631,"stargazers_count":37,"watchers_count":37,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":29,"mirror_url":null,"open_issues_count":58,"forks":29,"open_issues":58,"watchers":37,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/pgmpy/pgmpy/pulls/282"},"html":{"href":"https://github.com/pgmpy/pgmpy/pull/282"},"issue":{"href":"https://api.github.com/repos/pgmpy/pgmpy/issues/282"},"comments":{"href":"https://api.github.com/repos/pgmpy/pgmpy/issues/282/comments"},"review_comments":{"href":"https://api.github.com/repos/pgmpy/pgmpy/pulls/282/comments"},"review_comment":{"href":"https://api.github.com/repos/pgmpy/pgmpy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pgmpy/pgmpy/pulls/282/commits"},"statuses":{"href":"https://api.github.com/repos/pgmpy/pgmpy/statuses/029dc2f2d8fa6fc5cb63e6c019b4744506c5e5d5"}}}}