Skip to content

Commit

Permalink
Fixing doctests and making refinement_generic.pyx know the parent.
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis Scrimshaw committed Oct 3, 2018
1 parent 0a25f1a commit 2396cf0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/sage/groups/perm_gps/partn_ref2/refinement_generic.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from sage.groups.perm_gps.partn_ref.data_structures cimport OrbitPartition, PartitionStack
from sage.libs.gap.element cimport GapElement, GapElement_Permutation
from sage.structure.parent cimport Parent

cdef extern from "refinement_generic.h":
cdef long *global_refine_vals_array
Expand All @@ -35,6 +36,7 @@ cdef class LabelledBranching:
cdef int *father
cdef int *act_perm
cpdef GapElement group, ClosureGroup
cdef Parent sym_gp
cdef bint has_empty_intersection(self, PartitionStack * part)
cpdef add_gen(self, GapElement_Permutation gen)

Expand Down
5 changes: 3 additions & 2 deletions src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,13 @@ cdef class LabelledBranching:
sage: L = LabelledBranching(3)
"""
from sage.libs.gap.libgap import libgap
from sage.groups.perm_gps.permgroup_named import SymmetricGroup

self.n = n
self.group = libgap.eval("Group(())")
self.ClosureGroup = libgap.eval("ClosureGroup")
self.father = < int *> sig_malloc(n * sizeof(int))
self.sym_gp = SymmetricGroup(self.n)
if self.father is NULL:
raise MemoryError('allocating LabelledBranching')
self.act_perm = < int *> sig_malloc(n * sizeof(int))
Expand Down Expand Up @@ -433,8 +435,7 @@ cdef class LabelledBranching:
[(1,2,3)]
"""
from sage.libs.gap.libgap import libgap

return libgap.SmallGeneratingSet(self.group).sage()
return libgap.SmallGeneratingSet(self.group).sage(parent=self.sym_gp)

def get_order(self):
r"""
Expand Down
14 changes: 12 additions & 2 deletions src/sage/libs/gap/libgap.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,24 @@ equivalent::
sage: libgap.eval('5/3 + 7*E(3)').sage()
7*zeta3 + 5/3
sage: generators = libgap.AlternatingGroup(4).GeneratorsOfGroup().sage()
sage: gens_of_group = libgap.AlternatingGroup(4).GeneratorsOfGroup()
sage: generators = gens_of_group.sage()
sage: generators # a Sage list of Sage permutations!
[(1,2,3), (2,3,4)]
[[2, 3, 1], [1, 3, 4, 2]]
sage: PermutationGroup(generators).cardinality() # computed in Sage
12
sage: libgap.AlternatingGroup(4).Size() # computed in GAP
12
We can also specify which group in Sage the permutations should
consider themselves as elements of when converted to Sage::
sage: A4 = groups.permutation.Alternating(4)
sage: generators = gens_of_group.sage(parent=A4); generators
[(1,2,3), (2,3,4)]
sage: all(gen.parent() is A4 for gen in generators)
True
So far, the following GAP data types can be directly converted to the
corresponding Sage datatype:
Expand Down

0 comments on commit 2396cf0

Please sign in to comment.