Skip to content

Commit

Permalink
sagemathgh-38660: simplifications in some libgap calls
Browse files Browse the repository at this point in the history
by avoiding multiple calls of `libgap.eval`

### 📝 Checklist

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

URL: sagemath#38660
Reported by: Frédéric Chapoton
Reviewer(s): Travis Scrimshaw
  • Loading branch information
Release Manager committed Sep 16, 2024
2 parents e90b0b0 + d2ff956 commit 68ad182
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
4 changes: 2 additions & 2 deletions build/pkgs/configure/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
tarball=configure-VERSION.tar.gz
sha1=d2f8c0bc6c40a0e3e8f7cb0deebee5e7bc7da501
sha256=cde422cec1dc104f4f4b1369167a17cc77519186180bfc14322d078881581c50
sha1=3df2b29a0be22e74bc2f58297e8848d44d62a1ed
sha256=0e6edf9ba6dcd3c318ef0554940428370fb686403339cbc105cad0aa9296d7e3
2 changes: 1 addition & 1 deletion build/pkgs/configure/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
27fce1faa78ef19b8c43287016f0acbdf0fa169a
63276c5d5afef5f2965464612d0bf399a14b041d
6 changes: 3 additions & 3 deletions src/sage/algebras/quantum_groups/quantum_group_gap.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ def counit(self, elt):
constant = R(str(ext_rep.pop(2 * i))) # Pop the coefficient
break
# To reconstruct, we need the following
F = libgap.eval('ElementsFamily')(libgap.eval('FamilyObj')(self._libgap))
F = self._libgap.FamilyObj().ElementsFamily()
elt = F.ObjByExtRep(ext_rep)
co = self._libgap.CounitMap()
return R(str(co(elt))) + constant
Expand Down Expand Up @@ -2330,7 +2330,7 @@ def _construct_monomial(self, k):
sage: B._construct_monomial((3,0,1))
F[a1]^(3)*F[a2]
"""
F = libgap.eval('ElementsFamily')(libgap.eval('FamilyObj')(self._libgap))
F = self._libgap.FamilyObj().ElementsFamily()
one = self._libgap_base.One()
data = []
for i, val in enumerate(k):
Expand Down Expand Up @@ -2684,7 +2684,7 @@ def _unpickle_generic_element(parent, data):
sage: loads(dumps(x)) == x # indirect doctest
True
"""
F = libgap.eval('ElementsFamily')(libgap.eval('FamilyObj')(parent._libgap))
F = parent._libgap.FamilyObj().ElementsFamily()
ret = []
# We need to multiply by this to get the right type in GAP
one = parent._libgap_base.One()
Expand Down
33 changes: 17 additions & 16 deletions src/sage/groups/perm_gps/permgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2974,20 +2974,21 @@ def semidirect_product(self, N, mapping, check=True):
raise ValueError(msg)

# create a parallel list of the automorphisms of N in GAP
libgap.eval('N := Group({})'.format(list(N.gens())))
gens_string = ",".join(str(x) for x in N.gens())
homomorphism_cmd = 'alpha := GroupHomomorphismByImages(N, N, [{0}],[{1}])'
libgap.eval('morphisms := []')
N_gap = libgap.eval(f'Group({list(N.gens())})')
morphisms = libgap.eval('[]')
libgap_gens = N_gap.GeneratorsOfGroup()
for alpha in mapping[1]:
images_string = ",".join(str(alpha(n)) for n in N.gens())
libgap.eval(homomorphism_cmd.format(gens_string, images_string))
libgap.eval('Add(morphisms, alpha)')
images = [alpha(g) for g in N.gens()]
alpha_gap = N_gap.GroupHomomorphismByImages(N_gap,
libgap_gens, images)
morphisms.Add(alpha_gap)
# create the necessary homomorphism from self into the
# automorphism group of N in GAP
libgap.eval('H := Group({0})'.format(mapping[0]))
libgap.eval('phi := GroupHomomorphismByImages(H, AutomorphismGroup(N),{},morphisms)'.format(mapping[0]))
libgap.eval('sdp := SemidirectProduct(H, phi, N)')
return PermutationGroup(gap_group='sdp')
H = libgap.eval(f'Group({mapping[0]})')
phi = H.GroupHomomorphismByImages(N_gap.AutomorphismGroup(),
H.GeneratorsOfGroup(), morphisms)
sdp = H.SemidirectProduct(phi, N_gap)
return PermutationGroup(gap_group=sdp)

def holomorph(self):
r"""
Expand Down Expand Up @@ -3047,11 +3048,11 @@ def holomorph(self):
- Kevin Halasz (2012-08-14)
"""
libgap.eval('G := Group({})'.format(list(self.gens())))
libgap.eval('aut := AutomorphismGroup(G)')
libgap.eval('alpha := InverseGeneralMapping(NiceMonomorphism(aut))')
libgap.eval('product := SemidirectProduct(NiceObject(aut),alpha,G)')
return PermutationGroup(gap_group='product')
G = libgap.eval(f'Group({list(self.gens())})')
aut = G.AutomorphismGroup()
alpha = aut.NiceMonomorphism().InverseGeneralMapping()
product = aut.NiceObject().SemidirectProduct(alpha, G)
return PermutationGroup(gap_group=product)

def subgroup(self, gens=None, gap_group=None, domain=None, category=None, canonicalize=True, check=True):
"""
Expand Down

0 comments on commit 68ad182

Please sign in to comment.