{"action":"created","comment":{"url":"https://api.github.com/repos/pgmpy/pgmpy/pulls/comments/42720792","id":42720792,"diff_hunk":"@@ -133,16 +133,35 @@ def remove_factors(self, *factors):\n         >>> from pgmpy.factors import Factor\n         >>> G = FactorGraph()\n         >>> G.add_nodes_from(['a', 'b', 'c'])\n-        >>> G.add_nodes_from(['phi1', 'phi2'])\n-        >>> G.add_edges_from([('a', 'phi1'), ('b', 'phi1'),\n-        ...                   ('b', 'phi2'), ('c', 'phi2')])\n         >>> phi1 = Factor(['a', 'b'], [2, 2], np.random.rand(4))\n-        >>> G.add_factors(phi1)\n+         >>> G.add_factors(phi1)\n         >>> G.remove_factors(phi1)\n         \"\"\"\n         for factor in factors:\n             self.factors.remove(factor)\n \n+    def get_cardinality(self):\n+        \"\"\"\n+        >>> from pgmpy.models import FactorGraph\n+        >>> from pgmpy.factors import Factor\n+        >>> G = FactorGraph()\n+        >>> G.add_nodes_from(['a', 'b', 'c'])\n+        >>> phi1 = Factor(['a', 'b'], [2, 2], np.random.rand(4))\n+        >>> phi2 = Factor(['b', 'c'], [2, 2], np.random.rand(4))\n+        >>> G.add_nodes_from([phi1, phi2])\n+        >>> G.add_edges_from([('a', phi1), ('b', phi1),\n+        ...                   ('b', phi2), ('c', phi2)])\n+        >>> G.add_factors(phi1, phi2)\n+        >>> G.get_cardinality()\n+            defaultdict(<class 'int'>, {'c': 2, 'b': 2, 'a': 2})\n+        \n+        \"\"\"\n+        cardinalities = defaultdict(int)","path":"pgmpy/models/FactorGraph.py","position":112,"original_position":107,"commit_id":"3f3b67d8f9c4de667d40ca51077d0cee72223637","original_commit_id":"89d61ea926d46ef2fce520504911021795b5932b","user":{"login":"yashu-seth","id":14197921,"avatar_url":"https://avatars.githubusercontent.com/u/14197921?v=3","gravatar_id":"","url":"https://api.github.com/users/yashu-seth","html_url":"https://github.com/yashu-seth","followers_url":"https://api.github.com/users/yashu-seth/followers","following_url":"https://api.github.com/users/yashu-seth/following{/other_user}","gists_url":"https://api.github.com/users/yashu-seth/gists{/gist_id}","starred_url":"https://api.github.com/users/yashu-seth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yashu-seth/subscriptions","organizations_url":"https://api.github.com/users/yashu-seth/orgs","repos_url":"https://api.github.com/users/yashu-seth/repos","events_url":"https://api.github.com/users/yashu-seth/events{/privacy}","received_events_url":"https://api.github.com/users/yashu-seth/received_events","type":"User","site_admin":false},"body":"@ankurankan if we don't want to add factors attribute in the <code>UndirectedGraph</code> we can add another derived class from it that can act as a parent class for MarkovModel, FactorGraph and ClusterGraph. I think it can save a lot of redundancy.","created_at":"2015-10-22T08:05:37Z","updated_at":"2015-10-22T08:05:37Z","html_url":"https://github.com/pgmpy/pgmpy/pull/491#discussion_r42720792","pull_request_url":"https://api.github.com/repos/pgmpy/pgmpy/pulls/491","_links":{"self":{"href":"https://api.github.com/repos/pgmpy/pgmpy/pulls/comments/42720792"},"html":{"href":"https://github.com/pgmpy/pgmpy/pull/491#discussion_r42720792"},"pull_request":{"href":"https://api.github.com/repos/pgmpy/pgmpy/pulls/491"}}},"pull_request":{"url":"https://api.github.com/repos/pgmpy/pgmpy/pulls/491","id":47669285,"html_url":"https://github.com/pgmpy/pgmpy/pull/491","diff_url":"https://github.com/pgmpy/pgmpy/pull/491.diff","patch_url":"https://github.com/pgmpy/pgmpy/pull/491.patch","issue_url":"https://api.github.com/repos/pgmpy/pgmpy/issues/491","number":491,"state":"open","locked":false,"title":"updates in check_model method","user":{"login":"yashu-seth","id":14197921,"avatar_url":"https://avatars.githubusercontent.com/u/14197921?v=3","gravatar_id":"","url":"https://api.github.com/users/yashu-seth","html_url":"https://github.com/yashu-seth","followers_url":"https://api.github.com/users/yashu-seth/followers","following_url":"https://api.github.com/users/yashu-seth/following{/other_user}","gists_url":"https://api.github.com/users/yashu-seth/gists{/gist_id}","starred_url":"https://api.github.com/users/yashu-seth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yashu-seth/subscriptions","organizations_url":"https://api.github.com/users/yashu-seth/orgs","repos_url":"https://api.github.com/users/yashu-seth/repos","events_url":"https://api.github.com/users/yashu-seth/events{/privacy}","received_events_url":"https://api.github.com/users/yashu-seth/received_events","type":"User","site_admin":false},"body":"@ankurankan I have removed cardinalities from the model attributes but it seems it is being used at other places as well. Should cardinalities be computed every single time it is required? Is there a particular problem in having it as an attribute?","created_at":"2015-10-14T14:49:41Z","updated_at":"2015-10-22T08:05:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8e3d08cc2aadc36e7896a82800d2227257ea3565","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pgmpy/pgmpy/pulls/491/commits","review_comments_url":"https://api.github.com/repos/pgmpy/pgmpy/pulls/491/comments","review_comment_url":"https://api.github.com/repos/pgmpy/pgmpy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pgmpy/pgmpy/issues/491/comments","statuses_url":"https://api.github.com/repos/pgmpy/pgmpy/statuses/3f3b67d8f9c4de667d40ca51077d0cee72223637","head":{"label":"yashu-seth:tests_for_check_model_issue#272","ref":"tests_for_check_model_issue#272","sha":"3f3b67d8f9c4de667d40ca51077d0cee72223637","user":{"login":"yashu-seth","id":14197921,"avatar_url":"https://avatars.githubusercontent.com/u/14197921?v=3","gravatar_id":"","url":"https://api.github.com/users/yashu-seth","html_url":"https://github.com/yashu-seth","followers_url":"https://api.github.com/users/yashu-seth/followers","following_url":"https://api.github.com/users/yashu-seth/following{/other_user}","gists_url":"https://api.github.com/users/yashu-seth/gists{/gist_id}","starred_url":"https://api.github.com/users/yashu-seth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yashu-seth/subscriptions","organizations_url":"https://api.github.com/users/yashu-seth/orgs","repos_url":"https://api.github.com/users/yashu-seth/repos","events_url":"https://api.github.com/users/yashu-seth/events{/privacy}","received_events_url":"https://api.github.com/users/yashu-seth/received_events","type":"User","site_admin":false},"repo":{"id":42327600,"name":"pgmpy","full_name":"yashu-seth/pgmpy","owner":{"login":"yashu-seth","id":14197921,"avatar_url":"https://avatars.githubusercontent.com/u/14197921?v=3","gravatar_id":"","url":"https://api.github.com/users/yashu-seth","html_url":"https://github.com/yashu-seth","followers_url":"https://api.github.com/users/yashu-seth/followers","following_url":"https://api.github.com/users/yashu-seth/following{/other_user}","gists_url":"https://api.github.com/users/yashu-seth/gists{/gist_id}","starred_url":"https://api.github.com/users/yashu-seth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yashu-seth/subscriptions","organizations_url":"https://api.github.com/users/yashu-seth/orgs","repos_url":"https://api.github.com/users/yashu-seth/repos","events_url":"https://api.github.com/users/yashu-seth/events{/privacy}","received_events_url":"https://api.github.com/users/yashu-seth/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yashu-seth/pgmpy","description":"Python Library for Probabilistic Graphical Models","fork":true,"url":"https://api.github.com/repos/yashu-seth/pgmpy","forks_url":"https://api.github.com/repos/yashu-seth/pgmpy/forks","keys_url":"https://api.github.com/repos/yashu-seth/pgmpy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yashu-seth/pgmpy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yashu-seth/pgmpy/teams","hooks_url":"https://api.github.com/repos/yashu-seth/pgmpy/hooks","issue_events_url":"https://api.github.com/repos/yashu-seth/pgmpy/issues/events{/number}","events_url":"https://api.github.com/repos/yashu-seth/pgmpy/events","assignees_url":"https://api.github.com/repos/yashu-seth/pgmpy/assignees{/user}","branches_url":"https://api.github.com/repos/yashu-seth/pgmpy/branches{/branch}","tags_url":"https://api.github.com/repos/yashu-seth/pgmpy/tags","blobs_url":"https://api.github.com/repos/yashu-seth/pgmpy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yashu-seth/pgmpy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yashu-seth/pgmpy/git/refs{/sha}","trees_url":"https://api.github.com/repos/yashu-seth/pgmpy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yashu-seth/pgmpy/statuses/{sha}","languages_url":"https://api.github.com/repos/yashu-seth/pgmpy/languages","stargazers_url":"https://api.github.com/repos/yashu-seth/pgmpy/stargazers","contributors_url":"https://api.github.com/repos/yashu-seth/pgmpy/contributors","subscribers_url":"https://api.github.com/repos/yashu-seth/pgmpy/subscribers","subscription_url":"https://api.github.com/repos/yashu-seth/pgmpy/subscription","commits_url":"https://api.github.com/repos/yashu-seth/pgmpy/commits{/sha}","git_commits_url":"https://api.github.com/repos/yashu-seth/pgmpy/git/commits{/sha}","comments_url":"https://api.github.com/repos/yashu-seth/pgmpy/comments{/number}","issue_comment_url":"https://api.github.com/repos/yashu-seth/pgmpy/issues/comments{/number}","contents_url":"https://api.github.com/repos/yashu-seth/pgmpy/contents/{+path}","compare_url":"https://api.github.com/repos/yashu-seth/pgmpy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yashu-seth/pgmpy/merges","archive_url":"https://api.github.com/repos/yashu-seth/pgmpy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yashu-seth/pgmpy/downloads","issues_url":"https://api.github.com/repos/yashu-seth/pgmpy/issues{/number}","pulls_url":"https://api.github.com/repos/yashu-seth/pgmpy/pulls{/number}","milestones_url":"https://api.github.com/repos/yashu-seth/pgmpy/milestones{/number}","notifications_url":"https://api.github.com/repos/yashu-seth/pgmpy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yashu-seth/pgmpy/labels{/name}","releases_url":"https://api.github.com/repos/yashu-seth/pgmpy/releases{/id}","created_at":"2015-09-11T19:15:44Z","updated_at":"2015-09-11T19:15:45Z","pushed_at":"2015-10-22T07:44:07Z","git_url":"git://github.com/yashu-seth/pgmpy.git","ssh_url":"git@github.com:yashu-seth/pgmpy.git","clone_url":"https://github.com/yashu-seth/pgmpy.git","svn_url":"https://github.com/yashu-seth/pgmpy","homepage":null,"size":4614,"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":"38f92bf3c6711f343f34fcb4ad1f3b9981538f9e","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-10-22T03:29:42Z","pushed_at":"2015-10-22T07:44:07Z","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":7326,"stargazers_count":130,"watchers_count":130,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":55,"mirror_url":null,"open_issues_count":68,"forks":55,"open_issues":68,"watchers":130,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/pgmpy/pgmpy/pulls/491"},"html":{"href":"https://github.com/pgmpy/pgmpy/pull/491"},"issue":{"href":"https://api.github.com/repos/pgmpy/pgmpy/issues/491"},"comments":{"href":"https://api.github.com/repos/pgmpy/pgmpy/issues/491/comments"},"review_comments":{"href":"https://api.github.com/repos/pgmpy/pgmpy/pulls/491/comments"},"review_comment":{"href":"https://api.github.com/repos/pgmpy/pgmpy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pgmpy/pgmpy/pulls/491/commits"},"statuses":{"href":"https://api.github.com/repos/pgmpy/pgmpy/statuses/3f3b67d8f9c4de667d40ca51077d0cee72223637"}}}}