Skip to content

Commit ef3a6e9

Browse files
fchapotondimpase
authored andcommitted
more libgap in permutation groups ; get rid of _libgap_init_
1 parent e249bef commit ef3a6e9

File tree

5 files changed

+18
-28
lines changed

5 files changed

+18
-28
lines changed

src/sage/groups/perm_gps/permgroup_element.pyx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement):
410410
sage: k._gap_()
411411
(1,2)(3,5,6)
412412
sage: k._gap_().parent()
413-
Gap
413+
C library interface to GAP
414414
415415
List notation::
416416
@@ -835,13 +835,11 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement):
835835
sage: g._gap_()
836836
(1,2,3)(4,5)
837837
"""
838-
if gap is None:
839-
from sage.interfaces.gap import gap
840-
return gap(self._gap_init_())
838+
return self._libgap_()
841839

842840
def _libgap_(self):
843841
r"""
844-
Returns self as a libgap element
842+
Return ``self`` as a libgap element.
845843
846844
EXAMPLES::
847845
@@ -867,7 +865,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement):
867865
sage: p_libgap == p_pexpect
868866
True
869867
sage: type(p_libgap) == type(p_pexpect)
870-
False
868+
True
871869
872870
If the permutation element is built from a libgap element, it is cached
873871
and returned by this function::

src/sage/groups/perm_gps/permgroup_morphism.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def kernel(self):
8484
sage: G.is_isomorphic(pr1.kernel())
8585
True
8686
"""
87-
return self.domain().subgroup(gap_group=self._gap_().Kernel())
87+
return self.domain().subgroup(gap_group=self._libgap_().Kernel())
8888

8989
def image(self, J):
9090
r"""
@@ -133,10 +133,10 @@ def image(self, J):
133133
H = self.codomain()
134134
if J in self.domain():
135135
J = PermutationGroup([J])
136-
G = self._gap_().Image(J)
136+
G = self._libgap_().Image(J)
137137
return H.subgroup(gap_group=G).gens()[0]
138138
else:
139-
G = self._gap_().Image(J)
139+
G = self._libgap_().Image(J)
140140
return H.subgroup(gap_group=G)
141141

142142
def __call__(self, g):
@@ -210,7 +210,7 @@ def _repr_defn(self):
210210
"""
211211
return str(self._gap_hom).replace('\n', '')
212212

213-
def _gap_(self, gap=None):
213+
def _libgap_(self):
214214
r"""
215215
Return a GAP version of this morphism.
216216
@@ -220,7 +220,7 @@ def _gap_(self, gap=None):
220220
sage: G = PermutationGroup([[(1,2),(3,4)], [(1,2,3,4)]])
221221
sage: H = G.subgroup([G([(1,2,3,4)])])
222222
sage: phi = PermutationGroupMorphism_from_gap(H, G, gap.Identity)
223-
sage: phi._gap_()
223+
sage: phi._libgap_()
224224
Identity
225225
"""
226226
return self._gap_hom
@@ -239,7 +239,7 @@ def __call__(self, g):
239239
sage: [pr1(g) for g in G.gens()]
240240
[(3,7,5)(4,8,6), (1,2,6)(3,4,8)]
241241
"""
242-
return self.codomain()(self._gap_().Image(g))
242+
return self.codomain()(self._libgap_().Image(g))
243243

244244

245245
class PermutationGroupMorphism_im_gens(PermutationGroupMorphism):
@@ -295,7 +295,7 @@ def _repr_defn(self):
295295
"""
296296
return "%s -> %s" % (list(self.domain().gens()), self._images)
297297

298-
def _gap_(self):
298+
def _libgap_(self):
299299
r"""
300300
Return a GAP representation of this morphism.
301301
@@ -304,11 +304,10 @@ def _gap_(self):
304304
sage: G = CyclicPermutationGroup(4)
305305
sage: H = DihedralGroup(4)
306306
sage: phi = PermutationGroupMorphism_im_gens(G, H, map(H, G.gens()))
307-
sage: phi._gap_()
308-
GroupHomomorphismByImages( Group( [ (1,2,3,4) ] ), Group(
309-
[ (1,2,3,4), (1,4)(2,3) ] ), [ (1,2,3,4) ], [ (1,2,3,4) ] )
307+
sage: phi._libgap_()
308+
[ (1,2,3,4) ] -> [ (1,2,3,4) ]
310309
"""
311-
return self.domain()._gap_().GroupHomomorphismByImages(self.codomain(), self.domain().gens(), self._images)
310+
return self.domain()._libgap_().GroupHomomorphismByImages(self.codomain(), self.domain().gens(), self._images)
312311

313312

314313
def is_PermutationGroupMorphism(f) -> bool:

src/sage/libs/gap/element.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ cdef GapElement make_GapElement(parent, Obj obj) noexcept:
380380
sage: libgap(None)
381381
Traceback (most recent call last):
382382
...
383-
AttributeError: 'NoneType' object has no attribute '_libgap_init_'...
383+
AttributeError: 'NoneType' object has no attribute '_gap_init_'...
384384
"""
385385
cdef GapElement r = GapElement.__new__(GapElement)
386386
r._initialize(parent, obj)

src/sage/libs/gap/libgap.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ class Gap(Parent):
319319
return x._libgap_()
320320
except AttributeError:
321321
pass
322-
x = str(x._libgap_init_())
322+
x = str(x._gap_init_())
323323
return make_any_gap_element(self, gap_eval(x))
324324

325325
def _construct_matrix(self, M):
@@ -400,7 +400,7 @@ class Gap(Parent):
400400
cdef GapElement elem
401401

402402
if not isinstance(gap_command, str):
403-
gap_command = str(gap_command._libgap_init_())
403+
gap_command = str(gap_command._gap_init_())
404404

405405
initialize()
406406
elem = make_any_gap_element(self, gap_eval(gap_command))

src/sage/structure/sage_object.pyx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -755,14 +755,7 @@ cdef class SageObject:
755755

756756
def _libgap_(self):
757757
from sage.libs.gap.libgap import libgap
758-
return libgap.eval(self._libgap_init_())
759-
760-
def _libgap_init_(self):
761-
"""
762-
For consistency's sake we provide a ``_libgap_init_`` but in most cases
763-
we can use the same as ``_gap_init_`` here.
764-
"""
765-
return self._gap_init_()
758+
return libgap.eval(self._gap_init_())
766759

767760
def _gp_(self, G=None):
768761
if G is None:

0 commit comments

Comments
 (0)