Skip to content

Commit 7c23eaf

Browse files
committed
Fix compatibility for simplification isomorphism in SageMath versions
1 parent 2f15e47 commit 7c23eaf

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

darmonpoints/util.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from sage.calculus.var import var
1313
from sage.functions.generalized import sgn
1414
from sage.functions.transcendental import Function_zeta
15-
from sage.groups.finitely_presented import wrap_FpGroup
1615
from sage.interfaces.gp import gp
1716
from sage.libs.pari.all import PariError, pari
1817
from sage.matrix.all import Matrix, matrix
@@ -2170,11 +2169,18 @@ def simplification_isomorphism(G, return_inverse=False):
21702169
21712170
Uses GAP.
21722171
"""
2172+
21732173
I = G.gap().IsomorphismSimplifiedFpGroup()
21742174
domain = G
2175-
codomain = wrap_FpGroup(I.Range())
2176-
phi = lambda x: codomain(I.ImageElm(x.gap()))
2177-
ans = G.hom(phi, codomain)
2175+
try: # Sagemath >= 10.5
2176+
codomain = I.Range().sage()
2177+
phi = lambda x: codomain(I.ImageElm(x))
2178+
ans = G.hom(im_gens=[phi(x) for x in G.gap().GeneratorsOfGroup], codomain=codomain, check=False)
2179+
except NotImplementedError: # Sagemath < 10.5
2180+
from sage.groups.finitely_presented import wrap_FpGroup
2181+
codomain = wrap_FpGroup(I.Range())
2182+
phi = lambda x: codomain(I.ImageElm(x.gap()))
2183+
ans = G.hom(phi, codomain)
21782184
if return_inverse:
21792185
Iinv = I.InverseGeneralMapping()
21802186
phi_inv = lambda x: domain(Iinv.ImageElm(x.gap()))

0 commit comments

Comments
 (0)