Ticket #2850: 2850.patch

File 2850.patch, 11.1 KB (added by mhansen, 5 years ago)
  • sage/calculus/calculus.py

    # HG changeset patch
    # User Chris Swierczewski <cswiercz@gmail.com>
    # Date 1208214358 25200
    # Node ID 8667882edac7f1ca870cb3a24a5d2670b642b00d
    # Parent  c6b2f761c26fc29a64c4dc8b88c48c692570f1a2
    Doctests and docstrings for groups/perm_gps/permgroup.py (CURRENT SCORE permgroup.py: 98% (71 of 72))
    
    diff -r c6b2f761c26f -r 8667882edac7 sage/calculus/calculus.py
    a b class SymbolicExpression(RingElement): 
    11271127    ################################################################## 
    11281128    # The maxima one is special: 
    11291129    def _maxima_(self, session=None): 
     1130        r""" 
     1131        Method for coercing self as a Maxima \code{RingElement}. 
     1132        """ 
    11301133        if session is None: 
    11311134            return RingElement._maxima_(self, maxima) 
    11321135        else: 
    class SymbolicArithmetic(SymbolicOperati 
    44534456 
    44544457    def __call__(self, *args, **kwargs): 
    44554458        """ 
     4459        Method for handling a function call. 
     4460         
    44564461        EXAMPLES: 
    44574462            sage: x,y,z=var('x,y,z') 
    44584463             
  • sage/groups/perm_gps/permgroup.py

    diff -r c6b2f761c26f -r 8667882edac7 sage/groups/perm_gps/permgroup.py
    a b class PermutationGroup_generic(group.Fin 
    197197        True 
    198198    """ 
    199199    def __init__(self, gens, from_group = False, check=True): 
     200        r""" 
     201        Initializes instance of self, a \code{PermutationGroup_generic} object. 
     202        The flag from_group determines whether or not self should be 
     203        initialized as a Gap \code{Group} object and sent to the Gap 
     204        interpreter. If gens are Gap objects, then self is intialized as a Gap 
     205        \code{Group}. 
     206 
     207        EXAMPLES: 
     208        We explicitly construct the alternating group on four elements. 
     209            sage: A4 = PermutationGroup([[(1,2,3)],[(2,3,4)]]); A4 
     210            Permutation Group with generators [(1,2,3), (2,3,4)] 
     211            sage: A4.__init__([[(1,2,3)],[(2,3,4)]]); A4 
     212            Permutation Group with generators [(1,2,3), (2,3,4)] 
     213            sage: A4.center() 
     214            Permutation Group with generators [()] 
     215            sage: loads(A4.dumps()) == A4 
     216            True 
     217        """ 
    200218        if from_group and isinstance(gens, str): 
    201219            self.__gap = gens 
    202220            self.gens()  # so will check that group can be defined in GAP (e.g., no missing packages, etc.) 
    class PermutationGroup_generic(group.Fin 
    236254        self.gens() 
    237255 
    238256    def _gap_init_(self): 
     257        r""" 
     258        Returns a string showing how to declare / initialize self in Gap. 
     259        Stored in the \code{self.__gap} attribute. 
     260 
     261        EXAMPLES: 
     262        The \code{_gap_init_} method shows how you would define the Sage 
     263        \code{PermutationGroup_generic} object in Gap: 
     264            sage: A4 = PermutationGroup([[(1,2,3)],[(2,3,4)]]); A4 
     265            Permutation Group with generators [(1,2,3), (2,3,4)] 
     266            sage: A4._gap_init_() 
     267            'Group([((1,2,3)), ((2,3,4))])' 
     268        """ 
    239269        return self.__gap 
    240270 
    241271    def _magma_init_(self): 
     272        r""" 
     273        Returns a string showing how to declare / intialize self in Magma. 
     274 
     275        EXAMPLES: 
     276        We explicitly construct the alternating group on four elements. In 
     277        Magma, one would type the string below to construct the group. 
     278            sage: A4 = PermutationGroup([[(1,2,3)],[(2,3,4)]]); A4 
     279            Permutation Group with generators [(1,2,3), (2,3,4)] 
     280            sage: A4._magma_init_() 
     281            'PermutationGroup<4 | (1,2,3), (2,3,4)>' 
     282        """ 
    242283        g = str(self.gens())[1:-1] 
    243284        return 'PermutationGroup<%s | %s>'%(self.degree(), g) 
    244285 
    class PermutationGroup_generic(group.Fin 
    512553        return self._gap_().SmallGeneratingSet() 
    513554 
    514555    def gen(self, i): 
     556        r""" 
     557        Returns the ith generator of self; that is, the ith element of the 
     558        list \code{self.gens()}. 
     559 
     560        EXAMPLES: 
     561        We explicitly construct the alternating group on four elements: 
     562            sage: A4 = PermutationGroup([[(1,2,3)],[(2,3,4)]]); A4 
     563            Permutation Group with generators [(1,2,3), (2,3,4)] 
     564            sage: A4.gens() 
     565            ((1,2,3), (2,3,4)) 
     566            sage: A4.gen(0) 
     567            (1,2,3) 
     568            sage: A4.gen(1) 
     569            (2,3,4) 
     570            sage: A4.gens()[0]; A4.gens()[1] 
     571            (1,2,3) 
     572            (2,3,4) 
     573        """ 
    515574        return self.gens()[Integer(i)] 
    516575 
    517576    def cayley_table(self, names="x"): 
    class PermutationGroup_generic(group.Fin 
    682741            return O 
    683742     
    684743    def _repr_(self): 
     744        r""" 
     745        Returns a string describing self. 
     746 
     747        EXAMPLES: 
     748        We explicitly construct the alternating group on four elements. Note 
     749        that 
     750        the \code{AlternatingGroup} class has its own representation string: 
     751            sage: A4 = PermutationGroup([[(1,2,3)],[(2,3,4)]]); A4 
     752            Permutation Group with generators [(1,2,3), (2,3,4)] 
     753            sage: A4._repr_() 
     754            'Permutation Group with generators [(1,2,3), (2,3,4)]' 
     755            sage: AlternatingGroup(4)._repr_() 
     756            'Alternating group of order 4!/2 as a permutation group' 
     757        """ 
    685758        G = self.gens() 
    686759        return "Permutation Group with generators %s"%list(self.gens()) 
    687760 
    688761    def _latex_(self): 
     762        r""" 
     763        Method for describing self in LaTeX. Encapsulates \code{self.gens()} 
     764        in angle brackets to denote that self in generated by these elements. 
     765        Called by the \code{latex()} function. 
     766 
     767        EXAMPLES: 
     768        We explicitly construct the alternating group on four elements. 
     769            sage: A4 = PermutationGroup([[(1,2,3)],[(2,3,4)]]); A4 
     770            Permutation Group with generators [(1,2,3), (2,3,4)] 
     771            sage: latex(A4) 
     772            \langle (1,2,3), (2,3,4) \rangle 
     773            sage: A4._latex_() 
     774            '\\langle (1,2,3), (2,3,4) \\rangle' 
     775        """ 
    689776        return '\\langle ' + \ 
    690777               ', '.join([x._latex_() for x in self.gens()]) + ' \\rangle' 
    691778 
    class PermutationGroup_generic(group.Fin 
    729816 
    730817    def id(self): 
    731818        """ 
    732         Same as self.group_id() 
     819        (Same as self.group_id().) Return the ID code of this group, which is 
     820        a list of two integers. Requires "optional" database_gap-4.4.x package. 
     821 
     822        EXAMPLES: 
     823            sage: G = PermutationGroup([[(1,2,3),(4,5)], [(1,2)]]) 
     824            sage: G.group_id()    # requires optional database_gap-4.4.6 package 
     825            [12, 4] 
    733826        """ 
    734827        return self.group_id() 
    735828 
    class PermutationGroup_subgroup(Permutat 
    17131806    """ 
    17141807    def __init__(self, ambient, gens, from_group = False,  
    17151808                 check=True): 
     1809        r""" 
     1810        Initialization method for the \code{PermutationGroup_subgroup} class. 
     1811 
     1812        INPUTS: 
     1813            ambient -- the ambient group from which to construct this subgroup 
     1814            gens -- the generators of the subgroup 
     1815            from_group -- True: subroup is generated from a Gap string representation of the generators 
     1816            check-- True: checks if gens are indeed elements of the ambient group 
     1817             
     1818        EXAMPLES: 
     1819        An example involving the dihedral group on four elements. $D_8$ 
     1820        contains a cyclic subgroup or order four: 
     1821            sage: G = DihedralGroup(4) 
     1822            sage: H = CyclicPermutationGroup(4) 
     1823            sage: gens = H.gens(); gens 
     1824            ((1,2,3,4),) 
     1825            sage: S = PermutationGroup_subgroup(G,list(gens)) 
     1826            sage: S 
     1827            Subgroup of Dihedral group of order 8 as a permutation group generated by [(1,2,3,4)] 
     1828            sage: S.list() 
     1829            [(), (1,2,3,4), (1,3)(2,4), (1,4,3,2)] 
     1830            sage: S.ambient_group() 
     1831            Dihedral group of order 8 as a permutation group 
     1832 
     1833        However, $D_8$ does not contain a cyclic subgroup of order three: 
     1834            sage: G = DihedralGroup(4) 
     1835            sage: H = CyclicPermutationGroup(3) 
     1836            sage: gens = H.gens() 
     1837            sage: S = PermutationGroup_subgroup(G,list(gens)) 
     1838            Traceback (most recent call last): 
     1839            ... 
     1840            TypeError: each generator must be in the ambient group 
     1841        """ 
    17161842        if not isinstance(ambient, PermutationGroup_generic): 
    17171843            raise TypeError, "ambient (=%s) must be perm group."%ambient 
    17181844        if not isinstance(gens, list): 
    class PermutationGroup_subgroup(Permutat 
    17641890            return 1 
    17651891             
    17661892    def _repr_(self): 
     1893        r""" 
     1894        Returns a string representation / description of the permutation 
     1895        subgroup. 
     1896 
     1897        EXAMPLES: 
     1898        An example involving the dihedral group on four elements, $D_8$: 
     1899            sage: G = DihedralGroup(4) 
     1900            sage: H = CyclicPermutationGroup(4) 
     1901            sage: gens = H.gens() 
     1902            sage: S = PermutationGroup_subgroup(G, list(gens)) 
     1903            sage: S 
     1904            Subgroup of Dihedral group of order 8 as a permutation group generated by [(1,2,3,4)] 
     1905            sage: S._repr_() 
     1906            'Subgroup of Dihedral group of order 8 as a permutation group generated by [(1,2,3,4)]' 
     1907        """ 
    17671908        s = "Subgroup of %s generated by %s"%(self.ambient_group(), self.gens()) 
    17681909        return s 
    17691910 
    17701911    def _latex_(self): 
    17711912        r""" 
    17721913        Return latex representation of this group. 
     1914 
     1915        EXAMPLES: 
     1916        An example involving the dihedral group on four elements, $D_8$: 
     1917            sage: G = DihedralGroup(4) 
     1918            sage: H = CyclicPermutationGroup(4) 
     1919            sage: gens = H.gens() 
     1920            sage: S = PermutationGroup_subgroup(G, list(gens)) 
     1921            sage: latex(S) 
     1922            Subgroup of Dihedral group of order 8 as a permutation group generated by [(1,2,3,4)] 
     1923            sage: S._latex_() 
     1924            'Subgroup of Dihedral group of order 8 as a permutation group generated by [(1,2,3,4)]' 
    17731925        """ 
    17741926        return self._repr_() 
    17751927 
    class PermutationGroup_subgroup(Permutat 
    17771929    def ambient_group(self): 
    17781930        """ 
    17791931        Return the ambient group related to self. 
     1932 
     1933        EXAMPLES: 
     1934        An example involving the dihedral group on four elements, $D_8$: 
     1935            sage: G = DihedralGroup(4) 
     1936            sage: H = CyclicPermutationGroup(4) 
     1937            sage: gens = H.gens() 
     1938            sage: S = PermutationGroup_subgroup(G, list(gens)) 
     1939            sage: S.ambient_group() 
     1940            Dihedral group of order 8 as a permutation group 
     1941            sage: S.ambient_group() == G 
     1942            True 
    17801943        """ 
    17811944        return self.__ambient_group 
    17821945 
    17831946    def gens(self): 
    17841947        """ 
    17851948        Return the generators for this subgroup. 
     1949 
     1950        EXAMPLES: 
     1951        An example involving the dihedral group on four elements, $D_8$: 
     1952            sage: G = DihedralGroup(4) 
     1953            sage: H = CyclicPermutationGroup(4) 
     1954            sage: gens = H.gens() 
     1955            sage: S = PermutationGroup_subgroup(G, list(gens)) 
     1956            sage: S.gens() 
     1957            [(1,2,3,4)] 
     1958            sage: S.gens() == list(H.gens()) 
     1959            True 
    17861960        """ 
    17871961        return self.__gens 
    17881962