# 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
# 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 class MatrixGroup_gens(MatrixGroup_gap): sage: gens = [MS([[1,2],[-1,1]]),MS([[1,1],[0,1]])] sage: G = MatrixGroup(gens) sage: G._gap_init_() '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]])' '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)))' sage: gap(G._gap_init_()) Group([ [ [ Z(5)^0, Z(5) ], [ Z(5)^2, Z(5)^0 ] ], [ [ Z(5)^0, Z(5)^0 ], [ 0*Z(5), Z(5)^0 ] ] ]) """ gens_gap = ','.join([x._gap_init_() for x in self._gensG]) 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 class MatrixGroupElement(element.Multipl EXAMPLES: sage: k = GF(7); G = MatrixGroup([matrix(k,2,[1,1,0,1]), matrix(k,2,[1,0,0,2])]); g = G.1 sage: g._gap_init_() '[[Z(7)^0,0*Z(7)],[0*Z(7),Z(7)^2]]' '[[Z(7)^0,0*Z(7)],[0*Z(7),Z(7)^2]]*One(GF(7))' sage: gap(g._gap_init_()) [ [ Z(7)^0, 0*Z(7) ], [ 0*Z(7), Z(7)^2 ] ] It may be better to use gap(the matrix), since the result is cached. sage: gap(G.1) [ [ Z(7)^0, 0*Z(7) ], [ 0*Z(7), Z(7)^2 ] ] sage: gap(G.1).IsMatrix() true """ return self.__mat._gap_init_()
• ## sage/matrix/matrix1.pyx

`diff -r c18ec6a82eae -r ef8fad1e66ec sage/matrix/matrix1.pyx`
 a cdef class Matrix(matrix0.Matrix): def _gap_init_(self): """ Returns a string defining a gap representation of self EXAMPLES: sage: A = MatrixSpace(QQ,3)([1,2,3,4/3,5/3,6/4,7,8,9]) sage: g = gap(A); g [ [ 1, 2, 3 ], [ 4/3, 5/3, 3/2 ], [ 7, 8, 9 ] ] sage: A = MatrixSpace(QQ,3,3)([0,1,2,3,4,5,6,7,8]) sage: g=gap(A) sage: g [ [ 0, 1, 2 ], [ 3, 4, 5 ], [ 6, 7, 8 ] ] sage: g.CharacteristicPolynomial() x_1^3-12*x_1^2-18*x_1 sage: A = MatrixSpace(CyclotomicField(4),2,2)([0,1,2,3]) sage: g=gap(A) sage: g [ [ !0, !1 ], [ !2, !3 ] ] sage: g.IsMatrix() true """
• ## sage/rings/number_field/number_field.py

`diff -r c18ec6a82eae -r ef8fad1e66ec sage/rings/number_field/number_field.py`
 a class NumberField_generic(number_field_b def _gap_init_(self): """ Create a gap object representing self and return its name EXAMPLE: sage: F=CyclotomicField(8) sage: F.gen() zeta8 sage: F._gap_init_() # the following variable name is somehow random '\$sage2' sage: f=gap(F) sage: f sage: f.GeneratorsOfDivisionRing() [ (zeta8) ] """ if not self.is_absolute(): raise NotImplementedError, "Currently, only simple algebraic extensions are possible in gap" raise NotImplementedError, "Currently, only simple algebraic extensions are implemented in gap" if self.__dict__.has_key('_gap_name_'): # if it was constructed before return self.__dict__['_gap_name_'] G = sage.interfaces.gap.gap class NumberField_generic(number_field_b G.eval('%s := Indeterminate(%s,"x");;'%(varname,self.base_field()._gap_init_())) mp = self.polynomial().__repr__().replace('x',varname) OUTname = G._next_var_name() G.eval('%s := AlgebraicExtension(%s,%s);;'%(OUTname,self.base_field()._gap_init_(),mp)) G.eval('%s := AlgebraicExtension(%s,%s,"%s");;'%(OUTname,self.base_field()._gap_init_(),mp,str(self.gen()))) self.__dict__['_gap_name_'] = OUTname return OUTname
• ## sage/rings/number_field/number_field_element.pyx

`diff -r c18ec6a82eae -r ef8fad1e66ec sage/rings/number_field/number_field_element.pyx`
 a cdef class NumberFieldElement(FieldEleme def _gap_init_(self): """ Return gap string representation of self. Return gap string representation of self. If there is no gap object representing the parent of self, it is created first. EXAMPLES: sage: F=CyclotomicField(8) sage: p=F.gen()^2+2*F.gen()-3 sage: p zeta8^2 + 2*zeta8 - 3 sage: p._gap_init_() # The variable name in the output is somehow random 'GeneratorsOfField(\$sage2)[1]^2 + 2*GeneratorsOfField(\$sage2)[1] - 3' sage: gap(p._gap_init_()) (-3+2*zeta8+zeta8^2) """ s = self.__repr__() if self.parent().__dict__.has_key('_gap_name_'):