{"action":"created","comment":{"url":"https://api.github.com/repos/sympy/sympy/pulls/comments/47694441","id":47694441,"diff_hunk":"@@ -0,0 +1,157 @@\n+class FreeGroup(Group):\n+    r\"\"\"\n+    Called  with  a  positive  integer rank, FreeGroup\n+    returns a free group on rank generators. If optional\n+    argument name is given then the  generators are printed\n+    as name1, name2 etc., that is, each name is the\n+    concatenation of the string name and an integer from 1\n+    to range. The default for name is the string \"f\".\n+    \"\"\"\n+    is_group = True\n+\n+    def __new__(cls, *args, **kwargs):\n+        if not(len(args) == 1 or isinstance(args[0], int)):\n+            raise ValueError(\"\")\n+\n+        obj = Basic.__new__(cls, *args)\n+        obj._generators = args\n+        obj._order = S.Infinity\n+        obj._center = []\n+        obj._degree = obj._generators\n+        obj._is_abelian = False\n+\n+        return obj\n+\n+    def __init__(self, *args):\n+        if isinstance(args[0], int):\n+            self.gens_assign(*args)\n+\n+    def gens_assign(self, *args):\n+        f = var('f0:%s' %args)\n+\n+    def __repr__(self):\n+        str_form = '<free group on the generators[ '\n+        for i in range(len(self)):\n+            str_form += 'f%s, ' %i\n+        str_form = str_form[:-2]\n+        str_form += ' ]>'\n+        return str_form\n+\n+    def __len__(self):\n+        if isinstance(self.args[0], int):\n+            return self.args[0]\n+\n+    def __getitem__(self):\n+        return self._generators[i]\n+\n+\n+class Group(Basic):\n+    pass\n+\n+\n+class GroupElem(Basic):\n+    \"\"\"\n+    Group element definition\n+\n+    \"\"\"\n+\n+    def __init__(self, elem, group):\n+        if not isinstance(group, Group):\n+            raise TypeError(\"group is not a Group\")\n+        if not elem in group.Set:\n+            raise TypeError(\"elem is not an element of group\")\n+        self.elem = elem\n+        self.group = group\n+\n+    def __str__(self):\n+        return str(self.elem)\n+\n+    def __eq__(self, other):\n+        \"\"\"\n+        Two GroupElems are equal if they represent the same element,\n+        regardless of the Groups they belong to\n+        \"\"\"\n+\n+        if not isinstance(other, GroupElem):\n+            raise TypeError(\"other is not a GroupElem\")\n+        return self.elem == other.elem\n+\n+    def __ne__(self, other):\n+        return not self == other\n+\n+    def __hash__(self):\n+        return hash(self.elem)\n+\n+    def __mul__(self, other):\n+        \"\"\"\n+        If other is a group element, returns self * other.\n+        If other = n is an int, and self is in an abelian group, returns self**n\n+        \"\"\"\n+        if self.group.is_abelian() and isinstance(other, (int, long)):\n+            return self ** other\n+\n+        if not isinstance(other, GroupElem):\n+            raise TypeError(\"other must be a GroupElem, or an int \" \\\n+                            \"(if self's group is abelian)\")\n+        try:\n+            return GroupElem(self.group.bin_op((self.elem, other.elem)), \\\n+                             self.group)\n+        # This can return a TypeError in Funcion.__call__ if self and other\n+        # belong to different Groups. So we see if we can make sense of this\n+        # operation the other way around.\n+        except TypeError:\n+            return other.__rmul__(self)\n+\n+    def __rmul__(self, other):","path":"sympy/combinatorics/groups.py","position":105,"original_position":105,"commit_id":"5ef4e9244cb19b80e10d0daaa05a7237098f1e9b","original_commit_id":"5ef4e9244cb19b80e10d0daaa05a7237098f1e9b","user":{"login":"asmeurer","id":71486,"avatar_url":"https://avatars.githubusercontent.com/u/71486?v=3","gravatar_id":"","url":"https://api.github.com/users/asmeurer","html_url":"https://github.com/asmeurer","followers_url":"https://api.github.com/users/asmeurer/followers","following_url":"https://api.github.com/users/asmeurer/following{/other_user}","gists_url":"https://api.github.com/users/asmeurer/gists{/gist_id}","starred_url":"https://api.github.com/users/asmeurer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asmeurer/subscriptions","organizations_url":"https://api.github.com/users/asmeurer/orgs","repos_url":"https://api.github.com/users/asmeurer/repos","events_url":"https://api.github.com/users/asmeurer/events{/privacy}","received_events_url":"https://api.github.com/users/asmeurer/received_events","type":"User","site_admin":false},"body":"Oh right. Still, I think some code can be shared here. ","created_at":"2015-12-15T20:35:20Z","updated_at":"2015-12-15T20:35:20Z","html_url":"https://github.com/sympy/sympy/pull/10263#discussion_r47694441","pull_request_url":"https://api.github.com/repos/sympy/sympy/pulls/10263","_links":{"self":{"href":"https://api.github.com/repos/sympy/sympy/pulls/comments/47694441"},"html":{"href":"https://github.com/sympy/sympy/pull/10263#discussion_r47694441"},"pull_request":{"href":"https://api.github.com/repos/sympy/sympy/pulls/10263"}}},"pull_request":{"url":"https://api.github.com/repos/sympy/sympy/pulls/10263","id":53698035,"html_url":"https://github.com/sympy/sympy/pull/10263","diff_url":"https://github.com/sympy/sympy/pull/10263.diff","patch_url":"https://github.com/sympy/sympy/pull/10263.patch","issue_url":"https://api.github.com/repos/sympy/sympy/issues/10263","number":10263,"state":"open","locked":false,"title":"[WIP] FiniteGroup in SymPy","user":{"login":"gxyd","id":7712241,"avatar_url":"https://avatars.githubusercontent.com/u/7712241?v=3","gravatar_id":"","url":"https://api.github.com/users/gxyd","html_url":"https://github.com/gxyd","followers_url":"https://api.github.com/users/gxyd/followers","following_url":"https://api.github.com/users/gxyd/following{/other_user}","gists_url":"https://api.github.com/users/gxyd/gists{/gist_id}","starred_url":"https://api.github.com/users/gxyd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gxyd/subscriptions","organizations_url":"https://api.github.com/users/gxyd/orgs","repos_url":"https://api.github.com/users/gxyd/repos","events_url":"https://api.github.com/users/gxyd/events{/privacy}","received_events_url":"https://api.github.com/users/gxyd/received_events","type":"User","site_admin":false},"body":"\"NOT for Review right now\".\r\n\r\n```\r\n>>> g = FreeGroup(3)\r\n>>> g\r\n<free group on the generators[ f0, f1, f2 ]>\r\n>>> g.order()\r\nInfinity\r\n```\r\n\r\nCurrently i also discussed one question of GAP on\r\nhttp://math.stackexchange.com/questions/1576440/order-of-a-generator-element-of-free-group-in-gap\r\n\r\nwhich is for the Order of an element of FreeGroup.","created_at":"2015-12-15T12:41:35Z","updated_at":"2015-12-15T20:35:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b8e0e24154b8c68f1d8bc14ad4508a026b9960fb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sympy/sympy/pulls/10263/commits","review_comments_url":"https://api.github.com/repos/sympy/sympy/pulls/10263/comments","review_comment_url":"https://api.github.com/repos/sympy/sympy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sympy/sympy/issues/10263/comments","statuses_url":"https://api.github.com/repos/sympy/sympy/statuses/5ef4e9244cb19b80e10d0daaa05a7237098f1e9b","head":{"label":"gxyd:group_theory_PR4_FreeGroup","ref":"group_theory_PR4_FreeGroup","sha":"5ef4e9244cb19b80e10d0daaa05a7237098f1e9b","user":{"login":"gxyd","id":7712241,"avatar_url":"https://avatars.githubusercontent.com/u/7712241?v=3","gravatar_id":"","url":"https://api.github.com/users/gxyd","html_url":"https://github.com/gxyd","followers_url":"https://api.github.com/users/gxyd/followers","following_url":"https://api.github.com/users/gxyd/following{/other_user}","gists_url":"https://api.github.com/users/gxyd/gists{/gist_id}","starred_url":"https://api.github.com/users/gxyd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gxyd/subscriptions","organizations_url":"https://api.github.com/users/gxyd/orgs","repos_url":"https://api.github.com/users/gxyd/repos","events_url":"https://api.github.com/users/gxyd/events{/privacy}","received_events_url":"https://api.github.com/users/gxyd/received_events","type":"User","site_admin":false},"repo":{"id":23004594,"name":"sympy","full_name":"gxyd/sympy","owner":{"login":"gxyd","id":7712241,"avatar_url":"https://avatars.githubusercontent.com/u/7712241?v=3","gravatar_id":"","url":"https://api.github.com/users/gxyd","html_url":"https://github.com/gxyd","followers_url":"https://api.github.com/users/gxyd/followers","following_url":"https://api.github.com/users/gxyd/following{/other_user}","gists_url":"https://api.github.com/users/gxyd/gists{/gist_id}","starred_url":"https://api.github.com/users/gxyd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gxyd/subscriptions","organizations_url":"https://api.github.com/users/gxyd/orgs","repos_url":"https://api.github.com/users/gxyd/repos","events_url":"https://api.github.com/users/gxyd/events{/privacy}","received_events_url":"https://api.github.com/users/gxyd/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gxyd/sympy","description":"A computer algebra system written in pure Python","fork":true,"url":"https://api.github.com/repos/gxyd/sympy","forks_url":"https://api.github.com/repos/gxyd/sympy/forks","keys_url":"https://api.github.com/repos/gxyd/sympy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gxyd/sympy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gxyd/sympy/teams","hooks_url":"https://api.github.com/repos/gxyd/sympy/hooks","issue_events_url":"https://api.github.com/repos/gxyd/sympy/issues/events{/number}","events_url":"https://api.github.com/repos/gxyd/sympy/events","assignees_url":"https://api.github.com/repos/gxyd/sympy/assignees{/user}","branches_url":"https://api.github.com/repos/gxyd/sympy/branches{/branch}","tags_url":"https://api.github.com/repos/gxyd/sympy/tags","blobs_url":"https://api.github.com/repos/gxyd/sympy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gxyd/sympy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gxyd/sympy/git/refs{/sha}","trees_url":"https://api.github.com/repos/gxyd/sympy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gxyd/sympy/statuses/{sha}","languages_url":"https://api.github.com/repos/gxyd/sympy/languages","stargazers_url":"https://api.github.com/repos/gxyd/sympy/stargazers","contributors_url":"https://api.github.com/repos/gxyd/sympy/contributors","subscribers_url":"https://api.github.com/repos/gxyd/sympy/subscribers","subscription_url":"https://api.github.com/repos/gxyd/sympy/subscription","commits_url":"https://api.github.com/repos/gxyd/sympy/commits{/sha}","git_commits_url":"https://api.github.com/repos/gxyd/sympy/git/commits{/sha}","comments_url":"https://api.github.com/repos/gxyd/sympy/comments{/number}","issue_comment_url":"https://api.github.com/repos/gxyd/sympy/issues/comments{/number}","contents_url":"https://api.github.com/repos/gxyd/sympy/contents/{+path}","compare_url":"https://api.github.com/repos/gxyd/sympy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gxyd/sympy/merges","archive_url":"https://api.github.com/repos/gxyd/sympy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gxyd/sympy/downloads","issues_url":"https://api.github.com/repos/gxyd/sympy/issues{/number}","pulls_url":"https://api.github.com/repos/gxyd/sympy/pulls{/number}","milestones_url":"https://api.github.com/repos/gxyd/sympy/milestones{/number}","notifications_url":"https://api.github.com/repos/gxyd/sympy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gxyd/sympy/labels{/name}","releases_url":"https://api.github.com/repos/gxyd/sympy/releases{/id}","created_at":"2014-08-15T22:08:09Z","updated_at":"2015-07-04T12:40:41Z","pushed_at":"2015-12-15T12:40:37Z","git_url":"git://github.com/gxyd/sympy.git","ssh_url":"git@github.com:gxyd/sympy.git","clone_url":"https://github.com/gxyd/sympy.git","svn_url":"https://github.com/gxyd/sympy","homepage":"http://sympy.org/","size":73251,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"sympy:master","ref":"master","sha":"4bc92d1fd8cec503d66f8aed30f9348e7c8b08d1","user":{"login":"sympy","id":260832,"avatar_url":"https://avatars.githubusercontent.com/u/260832?v=3","gravatar_id":"","url":"https://api.github.com/users/sympy","html_url":"https://github.com/sympy","followers_url":"https://api.github.com/users/sympy/followers","following_url":"https://api.github.com/users/sympy/following{/other_user}","gists_url":"https://api.github.com/users/sympy/gists{/gist_id}","starred_url":"https://api.github.com/users/sympy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sympy/subscriptions","organizations_url":"https://api.github.com/users/sympy/orgs","repos_url":"https://api.github.com/users/sympy/repos","events_url":"https://api.github.com/users/sympy/events{/privacy}","received_events_url":"https://api.github.com/users/sympy/received_events","type":"Organization","site_admin":false},"repo":{"id":640534,"name":"sympy","full_name":"sympy/sympy","owner":{"login":"sympy","id":260832,"avatar_url":"https://avatars.githubusercontent.com/u/260832?v=3","gravatar_id":"","url":"https://api.github.com/users/sympy","html_url":"https://github.com/sympy","followers_url":"https://api.github.com/users/sympy/followers","following_url":"https://api.github.com/users/sympy/following{/other_user}","gists_url":"https://api.github.com/users/sympy/gists{/gist_id}","starred_url":"https://api.github.com/users/sympy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sympy/subscriptions","organizations_url":"https://api.github.com/users/sympy/orgs","repos_url":"https://api.github.com/users/sympy/repos","events_url":"https://api.github.com/users/sympy/events{/privacy}","received_events_url":"https://api.github.com/users/sympy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sympy/sympy","description":"A computer algebra system written in pure Python","fork":false,"url":"https://api.github.com/repos/sympy/sympy","forks_url":"https://api.github.com/repos/sympy/sympy/forks","keys_url":"https://api.github.com/repos/sympy/sympy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sympy/sympy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sympy/sympy/teams","hooks_url":"https://api.github.com/repos/sympy/sympy/hooks","issue_events_url":"https://api.github.com/repos/sympy/sympy/issues/events{/number}","events_url":"https://api.github.com/repos/sympy/sympy/events","assignees_url":"https://api.github.com/repos/sympy/sympy/assignees{/user}","branches_url":"https://api.github.com/repos/sympy/sympy/branches{/branch}","tags_url":"https://api.github.com/repos/sympy/sympy/tags","blobs_url":"https://api.github.com/repos/sympy/sympy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sympy/sympy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sympy/sympy/git/refs{/sha}","trees_url":"https://api.github.com/repos/sympy/sympy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sympy/sympy/statuses/{sha}","languages_url":"https://api.github.com/repos/sympy/sympy/languages","stargazers_url":"https://api.github.com/repos/sympy/sympy/stargazers","contributors_url":"https://api.github.com/repos/sympy/sympy/contributors","subscribers_url":"https://api.github.com/repos/sympy/sympy/subscribers","subscription_url":"https://api.github.com/repos/sympy/sympy/subscription","commits_url":"https://api.github.com/repos/sympy/sympy/commits{/sha}","git_commits_url":"https://api.github.com/repos/sympy/sympy/git/commits{/sha}","comments_url":"https://api.github.com/repos/sympy/sympy/comments{/number}","issue_comment_url":"https://api.github.com/repos/sympy/sympy/issues/comments{/number}","contents_url":"https://api.github.com/repos/sympy/sympy/contents/{+path}","compare_url":"https://api.github.com/repos/sympy/sympy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sympy/sympy/merges","archive_url":"https://api.github.com/repos/sympy/sympy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sympy/sympy/downloads","issues_url":"https://api.github.com/repos/sympy/sympy/issues{/number}","pulls_url":"https://api.github.com/repos/sympy/sympy/pulls{/number}","milestones_url":"https://api.github.com/repos/sympy/sympy/milestones{/number}","notifications_url":"https://api.github.com/repos/sympy/sympy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sympy/sympy/labels{/name}","releases_url":"https://api.github.com/repos/sympy/sympy/releases{/id}","created_at":"2010-04-30T20:37:14Z","updated_at":"2015-12-15T14:24:26Z","pushed_at":"2015-12-15T12:41:36Z","git_url":"git://github.com/sympy/sympy.git","ssh_url":"git@github.com:sympy/sympy.git","clone_url":"https://github.com/sympy/sympy.git","svn_url":"https://github.com/sympy/sympy","homepage":"http://sympy.org/","size":102383,"stargazers_count":2512,"watchers_count":2512,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1232,"mirror_url":null,"open_issues_count":2098,"forks":1232,"open_issues":2098,"watchers":2512,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sympy/sympy/pulls/10263"},"html":{"href":"https://github.com/sympy/sympy/pull/10263"},"issue":{"href":"https://api.github.com/repos/sympy/sympy/issues/10263"},"comments":{"href":"https://api.github.com/repos/sympy/sympy/issues/10263/comments"},"review_comments":{"href":"https://api.github.com/repos/sympy/sympy/pulls/10263/comments"},"review_comment":{"href":"https://api.github.com/repos/sympy/sympy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sympy/sympy/pulls/10263/commits"},"statuses":{"href":"https://api.github.com/repos/sympy/sympy/statuses/5ef4e9244cb19b80e10d0daaa05a7237098f1e9b"}}}}