Ticket #2348: fix_doctests_gap_numberfield.patch

File fix_doctests_gap_numberfield.patch, 5.8 KB (added by SimonKing, 14 years ago)

First apply the previous patch, then this patch. It fixes and extends doc tests related with the gap interface of number fields

  • sage/groups/matrix_gps/matrix_group.py

    # HG changeset patch
    # User Simon King <king@mathematik.uni-jena.de>
    # Date 1204495204 -3600
    # Node ID ef8fad1e66ecc929935e85bc53e097c7531c172e
    # Parent  c18ec6a82eae11e2a605f6a3e566e8113a2fe0f3
    Fix and extend doc tests related with the gap interface for number fields
    
    diff -r c18ec6a82eae -r ef8fad1e66ec sage/groups/matrix_gps/matrix_group.py
    a b class MatrixGroup_gens(MatrixGroup_gap): 
    628628            sage: gens = [MS([[1,2],[-1,1]]),MS([[1,1],[0,1]])]
    629629            sage: G = MatrixGroup(gens)
    630630            sage: G._gap_init_()
    631             'Group([[Z(5)^0,Z(5)^1],[Z(5)^2,Z(5)^0]],[[Z(5)^0,Z(5)^0],[0*Z(5),Z(5)^0]])'
     631            'Group([[Z(5)^0,Z(5)^1],[Z(5)^2,Z(5)^0]]*One(GF(5)),[[Z(5)^0,Z(5)^0],[0*Z(5),Z(5)^0]]*One(GF(5)))'
     632            sage: gap(G._gap_init_())
     633            Group([ [ [ Z(5)^0, Z(5) ], [ Z(5)^2, Z(5)^0 ] ],
     634              [ [ Z(5)^0, Z(5)^0 ], [ 0*Z(5), Z(5)^0 ] ] ])
    632635        """
    633636        gens_gap = ','.join([x._gap_init_() for x in self._gensG])
    634637        return 'Group(%s)'%gens_gap
  • sage/groups/matrix_gps/matrix_group_element.py

    diff -r c18ec6a82eae -r ef8fad1e66ec sage/groups/matrix_gps/matrix_group_element.py
    a b class MatrixGroupElement(element.Multipl 
    120120        EXAMPLES:
    121121            sage: k = GF(7); G = MatrixGroup([matrix(k,2,[1,1,0,1]), matrix(k,2,[1,0,0,2])]); g = G.1
    122122            sage: g._gap_init_()
    123             '[[Z(7)^0,0*Z(7)],[0*Z(7),Z(7)^2]]'
     123            '[[Z(7)^0,0*Z(7)],[0*Z(7),Z(7)^2]]*One(GF(7))'
    124124            sage: gap(g._gap_init_())
    125125            [ [ Z(7)^0, 0*Z(7) ], [ 0*Z(7), Z(7)^2 ] ]
    126126
    127127        It may be better to use gap(the matrix), since the result is cached.
    128128            sage: gap(G.1)
    129129            [ [ Z(7)^0, 0*Z(7) ], [ 0*Z(7), Z(7)^2 ] ]
     130            sage: gap(G.1).IsMatrix()
     131            true
    130132        """
    131133        return self.__mat._gap_init_()
    132134
  • sage/matrix/matrix1.pyx

    diff -r c18ec6a82eae -r ef8fad1e66ec sage/matrix/matrix1.pyx
    a b cdef class Matrix(matrix0.Matrix): 
    5151
    5252    def _gap_init_(self):
    5353        """
     54        Returns a string defining a gap representation of self
     55
    5456        EXAMPLES:
    55             sage: A = MatrixSpace(QQ,3)([1,2,3,4/3,5/3,6/4,7,8,9])
    56             sage: g = gap(A); g
    57             [ [ 1, 2, 3 ], [ 4/3, 5/3, 3/2 ], [ 7, 8, 9 ] ]
     57            sage: A = MatrixSpace(QQ,3,3)([0,1,2,3,4,5,6,7,8])
     58            sage: g=gap(A)
     59            sage: g
     60            [ [ 0, 1, 2 ], [ 3, 4, 5 ], [ 6, 7, 8 ] ]
     61            sage: g.CharacteristicPolynomial()
     62            x_1^3-12*x_1^2-18*x_1
     63            sage: A = MatrixSpace(CyclotomicField(4),2,2)([0,1,2,3])
     64            sage: g=gap(A)
     65            sage: g
     66            [ [ !0, !1 ], [ !2, !3 ] ]
    5867            sage: g.IsMatrix()
    5968            true
    6069        """
  • sage/rings/number_field/number_field.py

    diff -r c18ec6a82eae -r ef8fad1e66ec sage/rings/number_field/number_field.py
    a b class NumberField_generic(number_field_b 
    15841584    def _gap_init_(self):
    15851585        """
    15861586        Create a gap object representing self and return its name
     1587
     1588        EXAMPLE:
     1589            sage: F=CyclotomicField(8)
     1590            sage: F.gen()
     1591            zeta8
     1592            sage: F._gap_init_() # the following variable name is somehow random
     1593            '$sage2'
     1594            sage: f=gap(F)
     1595            sage: f
     1596            <algebraic extension over the Rationals of degree 4>
     1597            sage: f.GeneratorsOfDivisionRing()
     1598            [ (zeta8) ]
    15871599        """
    15881600        if not self.is_absolute():
    1589             raise NotImplementedError, "Currently, only simple algebraic extensions are possible in gap"
     1601            raise NotImplementedError, "Currently, only simple algebraic extensions are implemented in gap"
    15901602        if self.__dict__.has_key('_gap_name_'): # if it was constructed before
    15911603            return self.__dict__['_gap_name_']
    15921604        G = sage.interfaces.gap.gap
    class NumberField_generic(number_field_b 
    15941606        G.eval('%s := Indeterminate(%s,"x");;'%(varname,self.base_field()._gap_init_()))
    15951607        mp = self.polynomial().__repr__().replace('x',varname)
    15961608        OUTname = G._next_var_name()
    1597         G.eval('%s := AlgebraicExtension(%s,%s);;'%(OUTname,self.base_field()._gap_init_(),mp))
     1609        G.eval('%s := AlgebraicExtension(%s,%s,"%s");;'%(OUTname,self.base_field()._gap_init_(),mp,str(self.gen())))
    15981610        self.__dict__['_gap_name_'] = OUTname
    15991611        return OUTname
    16001612
  • sage/rings/number_field/number_field_element.pyx

    diff -r c18ec6a82eae -r ef8fad1e66ec sage/rings/number_field/number_field_element.pyx
    a b cdef class NumberFieldElement(FieldEleme 
    358358
    359359    def _gap_init_(self):
    360360        """
    361         Return gap string representation of self.
     361        Return gap string representation of self. If there is no gap object representing
     362        the parent of self, it is created first.
     363
     364        EXAMPLES:
     365            sage: F=CyclotomicField(8)
     366            sage: p=F.gen()^2+2*F.gen()-3
     367            sage: p
     368            zeta8^2 + 2*zeta8 - 3
     369            sage: p._gap_init_() # The variable name in the output is somehow random
     370            'GeneratorsOfField($sage2)[1]^2 + 2*GeneratorsOfField($sage2)[1] - 3'
     371            sage: gap(p._gap_init_())
     372            (-3+2*zeta8+zeta8^2)
    362373        """
    363374        s = self.__repr__()
    364375        if self.parent().__dict__.has_key('_gap_name_'):