{"action":"created","comment":{"url":"https://api.github.com/repos/sympy/sympy/pulls/comments/49162076","id":49162076,"diff_hunk":"@@ -267,32 +269,122 @@ def SymmetricGroup(n):\n     [1] http://en.wikipedia.org/wiki/Symmetric_group#Generators_and_relations\n \n     \"\"\"\n-    if n == 1:\n-        G = PermutationGroup([Permutation([0])])\n-    elif n == 2:\n-        G = PermutationGroup([Permutation([1, 0])])\n+    is_group = True\n+\n+    def __new__(cls, degree):\n+        if degree <= 0 or not isinstance(degree, int):\n+            raise ValueError(\"Degree of a SymmetricGroup should be a \"\n+                    \"positive integer\")\n+\n+        obj = Basic.__new__(cls, degree)\n+\n+        if degree < 3:\n+            obj._is_abelian = True\n+            obj._is_nilpotent = True\n+        else:\n+            obj._is_abelian = False\n+            obj._is_nilpotent = False\n+\n+        if degree < 5:\n+            obj._is_solvable = True\n+        else:\n+            obj._is_solvable = False\n+\n+        obj._is_transitive = True\n+        obj._is_sym = True\n+        obj._degree = degree\n+\n+        return obj\n+\n+    def __getitem__(self, i):\n+        return self.generators[i]\n+\n+    def __contains__(self, i):\n+        if not isinstance(i, Permutation):\n+            raise TypeError(\"A SymmetricGroup contains only Permutations as \"\n+                            \"elements, not elements of type %s\" % type(i))\n+        return self.contains(i)\n+\n+    def __len__(self):\n+        return len(self.generators)\n+\n+    def __mul__(self, other):\n+        pass\n+\n+    def center(self):\n+        if self.degree == 1 or self.degree == 2:\n+            return self\n+        else:\n+            return SymmetricGroup(1)\n+\n+    @property\n+    def generators(self):\n+        degree = self.degree\n+        if degree == 1:\n+            return [Permutation([0])]\n+        elif degree == 2:\n+            return [Permutation([1, 0])]\n+        else:\n+            a = list(range(1, degree))\n+            a.append(0)\n+            gen1 = _af_new(a)\n+            a = list(range(degree))\n+            a[0], a[1] = a[1], a[0]\n+            gen2 = _af_new(a)\n+            return [gen1, gen2]\n+\n+    @property\n+    def degree(self):\n+        return self._degree\n+\n+    def is_subgroup(self, other):\n+        if isinstance(other, SymmetricGroup):\n+            return self.degree <= other.degree\n+\n+    def contains(self, g):\n+        if not isinstance(g, Permutation):\n+            return False\n+        return g.size <= self.degree\n+\n+    @property\n+    def is_abelian(self):\n+        return self._is_abelian\n+\n+    @property\n+    def is_trivial(self):\n+        return self == SymmetricGroup(1)\n+\n+    def order(self):\n+        return factorial(self.degree)\n+\n+    def orbit(self, alpha):\n+        return set(list(range(self.degree)))\n+\n+    def stabilizer(self, alpha):\n+        if alpha >= self.degree or alpha < 0:\n+            raise ValueError(\"Such element is not there in the finite set on \"\n+                    \"which SymmetricGroup is defined\")\n+        gens = _stabilizer(self.degree, alpha)\n+        if gens == self.generators:\n+            return SymmetricGroup(self.degree)\n+        return PermutationGroup(gens)\n+\n+\n+def _stabilizer(degree, alpha):\n+    if degree == 1 or degree == 2:\n+        return [Permutation(degree - 1)]\n+    gen2_self = Permutation(degree - 1)(0, 1)\n+    a = list(range(degree))\n+    a.remove(alpha)\n+    gen1 = Permutation(*a)\n+    if alpha^gen2_self == alpha:","path":"sympy/combinatorics/named_groups.py","position":137,"original_position":137,"commit_id":"dcc8f2c89ad07393f782f131ae9b9b4dbfcc1b75","original_commit_id":"dcc8f2c89ad07393f782f131ae9b9b4dbfcc1b75","user":{"login":"jksuom","id":6929119,"avatar_url":"https://avatars.githubusercontent.com/u/6929119?v=3","gravatar_id":"","url":"https://api.github.com/users/jksuom","html_url":"https://github.com/jksuom","followers_url":"https://api.github.com/users/jksuom/followers","following_url":"https://api.github.com/users/jksuom/following{/other_user}","gists_url":"https://api.github.com/users/jksuom/gists{/gist_id}","starred_url":"https://api.github.com/users/jksuom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jksuom/subscriptions","organizations_url":"https://api.github.com/users/jksuom/orgs","repos_url":"https://api.github.com/users/jksuom/repos","events_url":"https://api.github.com/users/jksuom/events{/privacy}","received_events_url":"https://api.github.com/users/jksuom/received_events","type":"User","site_admin":false},"body":"Is this condition equivalent to ``alpha > 1``?","created_at":"2016-01-08T06:39:59Z","updated_at":"2016-01-08T06:39:59Z","html_url":"https://github.com/sympy/sympy/pull/10363#discussion_r49162076","pull_request_url":"https://api.github.com/repos/sympy/sympy/pulls/10363","_links":{"self":{"href":"https://api.github.com/repos/sympy/sympy/pulls/comments/49162076"},"html":{"href":"https://github.com/sympy/sympy/pull/10363#discussion_r49162076"},"pull_request":{"href":"https://api.github.com/repos/sympy/sympy/pulls/10363"}}},"pull_request":{"url":"https://api.github.com/repos/sympy/sympy/pulls/10363","id":55206856,"html_url":"https://github.com/sympy/sympy/pull/10363","diff_url":"https://github.com/sympy/sympy/pull/10363.diff","patch_url":"https://github.com/sympy/sympy/pull/10363.patch","issue_url":"https://api.github.com/repos/sympy/sympy/issues/10363","number":10363,"state":"open","locked":false,"title":"[WIP]`SymmetricGroup` is now a class not function","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":"See commit message for complete \"Why this?\".","created_at":"2016-01-06T12:17:11Z","updated_at":"2016-01-08T06:39:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9a6d417ba99fee855a3b98626758f05bf2f2a800","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sympy/sympy/pulls/10363/commits","review_comments_url":"https://api.github.com/repos/sympy/sympy/pulls/10363/comments","review_comment_url":"https://api.github.com/repos/sympy/sympy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sympy/sympy/issues/10363/comments","statuses_url":"https://api.github.com/repos/sympy/sympy/statuses/dcc8f2c89ad07393f782f131ae9b9b4dbfcc1b75","head":{"label":"gxyd:symmetric_group_class","ref":"symmetric_group_class","sha":"dcc8f2c89ad07393f782f131ae9b9b4dbfcc1b75","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":"2016-01-07T14:33:09Z","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":73467,"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":"713ca36cc2ae9b83cf0e0e63d7891d48f4c25037","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":"2016-01-08T03:27:58Z","pushed_at":"2016-01-08T06:38:07Z","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":102778,"stargazers_count":2539,"watchers_count":2539,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1269,"mirror_url":null,"open_issues_count":2123,"forks":1269,"open_issues":2123,"watchers":2539,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sympy/sympy/pulls/10363"},"html":{"href":"https://github.com/sympy/sympy/pull/10363"},"issue":{"href":"https://api.github.com/repos/sympy/sympy/issues/10363"},"comments":{"href":"https://api.github.com/repos/sympy/sympy/issues/10363/comments"},"review_comments":{"href":"https://api.github.com/repos/sympy/sympy/pulls/10363/comments"},"review_comment":{"href":"https://api.github.com/repos/sympy/sympy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sympy/sympy/pulls/10363/commits"},"statuses":{"href":"https://api.github.com/repos/sympy/sympy/statuses/dcc8f2c89ad07393f782f131ae9b9b4dbfcc1b75"}}}}