Skip to content

Commit

Permalink
Fix compatibility for simplification isomorphism in SageMath versions
Browse files Browse the repository at this point in the history
  • Loading branch information
mmasdeu committed Dec 17, 2024
1 parent 2f15e47 commit 7c23eaf
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions darmonpoints/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from sage.calculus.var import var
from sage.functions.generalized import sgn
from sage.functions.transcendental import Function_zeta
from sage.groups.finitely_presented import wrap_FpGroup
from sage.interfaces.gp import gp
from sage.libs.pari.all import PariError, pari
from sage.matrix.all import Matrix, matrix
Expand Down Expand Up @@ -2170,11 +2169,18 @@ def simplification_isomorphism(G, return_inverse=False):
Uses GAP.
"""

I = G.gap().IsomorphismSimplifiedFpGroup()
domain = G
codomain = wrap_FpGroup(I.Range())
phi = lambda x: codomain(I.ImageElm(x.gap()))
ans = G.hom(phi, codomain)
try: # Sagemath >= 10.5
codomain = I.Range().sage()
phi = lambda x: codomain(I.ImageElm(x))
ans = G.hom(im_gens=[phi(x) for x in G.gap().GeneratorsOfGroup], codomain=codomain, check=False)
except NotImplementedError: # Sagemath < 10.5
from sage.groups.finitely_presented import wrap_FpGroup
codomain = wrap_FpGroup(I.Range())
phi = lambda x: codomain(I.ImageElm(x.gap()))
ans = G.hom(phi, codomain)
if return_inverse:
Iinv = I.InverseGeneralMapping()
phi_inv = lambda x: domain(Iinv.ImageElm(x.gap()))
Expand Down

0 comments on commit 7c23eaf

Please sign in to comment.