Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
reflect deprecation of mutable isogenies in doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
yyyyx4 committed Aug 17, 2021
1 parent 3e10548 commit 69a15a2
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 29 deletions.
44 changes: 32 additions & 12 deletions src/sage/schemes/elliptic_curves/ell_curve_isogeny.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ class EllipticCurveIsogeny(EllipticCurveHom):
sage: f = X^2 - 2/5*i + 1/5
sage: phi= E.isogeny(f)
sage: isom = phi.codomain().isomorphism_to(E)
sage: phi.set_post_isomorphism(isom)
sage: phi = isom * phi
sage: phi.codomain() == phi.domain()
True
sage: phi.rational_maps()
Expand Down Expand Up @@ -1385,6 +1385,7 @@ def __clear_cached_values(self):
sage: old_hash = hash(phi)
sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism
sage: phi.set_post_isomorphism(WeierstrassIsomorphism(phi.codomain(), (-1,2,-3,4)))
...
sage: hash(phi) == old_hash
False
Expand All @@ -1394,6 +1395,7 @@ def __clear_cached_values(self):
sage: old_ratl_maps = phi.rational_maps()
sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism
sage: phi.set_post_isomorphism(WeierstrassIsomorphism(phi.codomain(), (-1,0,0,0)))
...
sage: old_ratl_maps == phi.rational_maps()
False
sage: old_ratl_maps[1] == -phi.rational_maps()[1]
Expand All @@ -1407,6 +1409,7 @@ def __clear_cached_values(self):
sage: old_ratl_maps = phi.rational_maps()
sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism
sage: phi.set_post_isomorphism(WeierstrassIsomorphism(phi.codomain(), (-13,13,-13,13)))
...
sage: old_hash == hash(phi)
False
sage: old_ratl_maps == phi.rational_maps()
Expand Down Expand Up @@ -1439,9 +1442,11 @@ def __perform_inheritance_housekeeping(self):
sage: E2 = phi.codomain()
sage: post_isom = WeierstrassIsomorphism(E2, (41, 37, 31, 29))
sage: phi.set_post_isomorphism(post_isom)
...
sage: E1pr = WeierstrassIsomorphism(E, (-1, 2, -3, 4)).codomain()
sage: pre_isom = E1pr.isomorphism_to(E)
sage: phi.set_pre_isomorphism(pre_isom)
...
"""
# one of the superclasses uses these fields
Expand Down Expand Up @@ -1664,6 +1669,7 @@ def __set_pre_isomorphism(self, domain, isomorphism):
sage: E1pr = WeierstrassIsomorphism(E, (-1, 2, -3, 4)).codomain()
sage: pre_isom = E1pr.isomorphism_to(E)
sage: phi.set_pre_isomorphism(pre_isom)
...
sage: phi._EllipticCurveIsogeny__set_pre_isomorphism(E, WeierstrassIsomorphism(E, (-1, 3, -3, 4)))
sage: E == phi.domain()
True
Expand Down Expand Up @@ -1712,6 +1718,7 @@ def __set_post_isomorphism(self, codomain, isomorphism):
sage: E2 = phi.codomain()
sage: isom = WeierstrassIsomorphism(E2, (-1,2,-3,4))
sage: phi.set_post_isomorphism(isom)
...
sage: phi._EllipticCurveIsogeny__set_post_isomorphism(E2, WeierstrassIsomorphism(phi.codomain(), (1,-2,3,-4)))
sage: E2 == phi.codomain()
True
Expand Down Expand Up @@ -2891,6 +2898,7 @@ def set_pre_isomorphism(self, preWI):
sage: Epr = E.short_weierstrass_model()
sage: isom = Epr.isomorphism_to(E)
sage: phi.set_pre_isomorphism(isom)
...
sage: phi.rational_maps()
((-6*x^4 - 3*x^3 + 12*x^2 + 10*x - 1)/(x^3 + x - 12), (3*x^7 + x^6*y - 14*x^6 - 3*x^5 + 5*x^4*y + 7*x^4 + 8*x^3*y - 8*x^3 - 5*x^2*y + 5*x^2 - 14*x*y + 14*x - 6*y - 6)/(x^6 + 2*x^4 + 7*x^3 + x^2 + 7*x - 11))
sage: phi(Epr((0,22)))
Expand All @@ -2908,7 +2916,9 @@ def set_pre_isomorphism(self, preWI):
sage: inv_isom = WeierstrassIsomorphism(E, (1,-2,5,10))
sage: Epr = inv_isom.codomain()
sage: isom = Epr.isomorphism_to(E)
sage: phi.set_pre_isomorphism(isom); phi
sage: phi.set_pre_isomorphism(isom)
...
sage: phi
Isogeny of degree 5 from Elliptic Curve defined by y^2 + 10*x*y + 20*y = x^3 + 27*x^2 + 6 over Finite Field of size 29 to Elliptic Curve defined by y^2 = x^3 + 20*x over Finite Field of size 29
sage: phi(Epr((12,1)))
(26 : 0 : 1)
Expand All @@ -2928,6 +2938,7 @@ def set_pre_isomorphism(self, preWI):
sage: Epr = E.short_weierstrass_model()
sage: isom = Epr.isomorphism_to(E)
sage: phi.set_pre_isomorphism(isom)
...
sage: phi
Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 - 13392*x - 1080432 over Rational Field to Elliptic Curve defined by y^2 + y = x^3 - x^2 - 7820*x - 263580 over Rational Field
sage: phi(Epr((168,1188)))
Expand Down Expand Up @@ -2982,6 +2993,7 @@ def set_post_isomorphism(self, postWI):
sage: phi = EllipticCurveIsogeny(E, x+18)
sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism
sage: phi.set_post_isomorphism(WeierstrassIsomorphism(phi.codomain(), (6,8,10,12)))
...
sage: phi
Isogeny of degree 3 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 31 to Elliptic Curve defined by y^2 + 24*x*y + 7*y = x^3 + 22*x^2 + 16*x + 20 over Finite Field of size 31
Expand All @@ -2991,9 +3003,11 @@ def set_post_isomorphism(self, postWI):
sage: E2 = phi.codomain()
sage: post_isom = E2.isomorphism_to(E)
sage: phi.set_post_isomorphism(post_isom)
...
sage: phi.rational_maps() == E.multiplication_by_m(3)
False
sage: phi.switch_sign()
...
sage: phi.rational_maps() == E.multiplication_by_m(3)
True
Expand Down Expand Up @@ -3056,6 +3070,7 @@ def get_pre_isomorphism(self):
sage: Epr = E.short_weierstrass_model()
sage: isom = Epr.isomorphism_to(E)
sage: phi.set_pre_isomorphism(isom)
...
sage: isom == phi.get_pre_isomorphism()
True
Expand Down Expand Up @@ -3085,6 +3100,7 @@ def get_post_isomorphism(self):
sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism
sage: isom = WeierstrassIsomorphism(phi.codomain(), (6,8,10,12))
sage: phi.set_post_isomorphism(isom)
...
sage: isom == phi.get_post_isomorphism()
True
Expand Down Expand Up @@ -3120,6 +3136,7 @@ def switch_sign(self):
sage: phi.rational_maps() == E.multiplication_by_m(3)
False
sage: phi.switch_sign()
...
sage: phi.rational_maps() == E.multiplication_by_m(3)
True
Expand All @@ -3132,6 +3149,7 @@ def switch_sign(self):
sage: phi.rational_maps()
((x^2 + 6*x + 4)/(x + 6), (x^2*y - 5*x*y + 8*x - 2*y)/(x^2 - 5*x + 2))
sage: phi.switch_sign()
...
sage: phi
Isogeny of degree 2 from Elliptic Curve defined by y^2 + 15*x*y + 12*y = x^3 + 3*x^2 + 7*x + 6 over Finite Field of size 17 to Elliptic Curve defined by y^2 + 15*x*y + 12*y = x^3 + 3*x^2 + 4*x + 8 over Finite Field of size 17
sage: phi.rational_maps()
Expand All @@ -3144,6 +3162,7 @@ def switch_sign(self):
sage: phi = EllipticCurveIsogeny(E, f)
sage: (xmap1, ymap1) = phi.rational_maps()
sage: phi.switch_sign()
...
sage: (xmap2, ymap2) = phi.rational_maps()
sage: xmap1 == xmap2
True
Expand All @@ -3157,6 +3176,7 @@ def switch_sign(self):
sage: phi.rational_maps()
((x^2 + (-a)*x - 2)/(x + (-a)), (x^2*y + (-2*a)*x*y + y)/(x^2 + (-2*a)*x - 1))
sage: phi.switch_sign()
...
sage: phi.rational_maps()
((x^2 + (-a)*x - 2)/(x + (-a)), (-x^2*y + (2*a)*x*y - y)/(x^2 + (-2*a)*x - 1))
Expand Down Expand Up @@ -3203,15 +3223,15 @@ def is_normalized(self, via_formal=True, check_by_pullback=True):
sage: phi.is_normalized()
True
sage: isom = WeierstrassIsomorphism(phi.codomain(), (3, 0, 0, 0))
sage: phi.set_post_isomorphism(isom)
sage: phi = isom * phi
sage: phi.is_normalized()
False
sage: isom = WeierstrassIsomorphism(phi.codomain(), (5, 0, 0, 0))
sage: phi.set_post_isomorphism(isom)
sage: phi = isom * phi
sage: phi.is_normalized()
True
sage: isom = WeierstrassIsomorphism(phi.codomain(), (1, 1, 1, 1))
sage: phi.set_post_isomorphism(isom)
sage: phi = isom * phi
sage: phi.is_normalized()
True
Expand All @@ -3222,15 +3242,15 @@ def is_normalized(self, via_formal=True, check_by_pullback=True):
sage: isom = WeierstrassIsomorphism(phi.codomain(), (alpha, 0, 0, 0))
sage: phi.is_normalized()
True
sage: phi.set_post_isomorphism(isom)
sage: phi = isom * phi
sage: phi.is_normalized()
False
sage: isom = WeierstrassIsomorphism(phi.codomain(), (1/alpha, 0, 0, 0))
sage: phi.set_post_isomorphism(isom)
sage: phi = isom * phi
sage: phi.is_normalized()
True
sage: isom = WeierstrassIsomorphism(phi.codomain(), (1, 1, 1, 1))
sage: phi.set_post_isomorphism(isom)
sage: phi = isom * phi
sage: phi.is_normalized()
True
Expand All @@ -3241,15 +3261,15 @@ def is_normalized(self, via_formal=True, check_by_pullback=True):
sage: isom = WeierstrassIsomorphism(phi.codomain(), (2, 0, 0, 0))
sage: phi.is_normalized()
True
sage: phi.set_post_isomorphism(isom)
sage: phi = isom * phi
sage: phi.is_normalized()
False
sage: isom = WeierstrassIsomorphism(phi.codomain(), (1/2, 0, 0, 0))
sage: phi.set_post_isomorphism(isom)
sage: phi = isom * phi
sage: phi.is_normalized()
True
sage: isom = WeierstrassIsomorphism(phi.codomain(), (1, 1, 1, 1))
sage: phi.set_post_isomorphism(isom)
sage: phi = isom * phi
sage: phi.is_normalized()
True
"""
Expand Down Expand Up @@ -3415,7 +3435,7 @@ def dual(self):
sage: phi
Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + 11*x + 11 over Finite Field of size 103 to Elliptic Curve defined by y^2 = x^3 + 25*x + 80 over Finite Field of size 103
sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism
sage: phi.set_post_isomorphism(WeierstrassIsomorphism(phi.codomain(),(5,0,1,2)))
sage: phi = WeierstrassIsomorphism(phi.codomain(),(5,0,1,2)) * phi
sage: phi.dual().dual() == phi
True
Expand Down
3 changes: 1 addition & 2 deletions src/sage/schemes/elliptic_curves/isogeny_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,8 +840,7 @@ def add_tup(t):
if js: # seen codomain already -- up to isomorphism
j = js[0]
if phi.codomain()!=curves[j]:
iso = E2.isomorphism_to(curves[j])
phi.set_post_isomorphism(iso)
phi = E2.isomorphism_to(curves[j]) * phi
assert phi.domain()==curves[i] and phi.codomain()==curves[j]
add_tup([i,j,d,phi])
else:
Expand Down
27 changes: 12 additions & 15 deletions src/sage/schemes/elliptic_curves/isogeny_small_degree.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def isogenies_prime_degree_genus_0(E, l=None, minimal_models=True):
from sage.rings.number_field.number_field_base import is_NumberField
model = "minimal" if minimal_models and is_NumberField(F) else None
isogs = [E1.isogeny(kernel=ker, model=model) for ker in kernels]
[isog.set_pre_isomorphism(w) for isog in isogs]
isogs = [isog * w for isog in isogs]
return isogs

if l is None:
Expand Down Expand Up @@ -660,7 +660,7 @@ def isogenies_sporadic_Q(E, l=None, minimal_models=True):
from sage.rings.number_field.number_field_base import is_NumberField
model = "minimal" if minimal_models and is_NumberField(F) else None
isog = Ew.isogeny(kernel=ker, degree=l, model=model, check=False)
isog.set_pre_isomorphism(E_to_Ew)
isog = isog * E_to_Ew
return [isog]


Expand Down Expand Up @@ -822,7 +822,7 @@ def isogenies_5_0(E, minimal_models=True):
model = "minimal" if minimal_models and is_NumberField(F) else None
isogs = [Ew.isogeny(x**2+beta*x+gamma, model=model) for beta,gamma in zip(betas,gammas)]
iso = E.isomorphism_to(Ew)
[isog.set_pre_isomorphism(iso) for isog in isogs]
isogs = [isog * iso for isog in isogs]
return isogs

def isogenies_5_1728(E, minimal_models=True):
Expand Down Expand Up @@ -921,13 +921,13 @@ def isogenies_5_1728(E, minimal_models=True):
if square1:
i = F(-1).sqrt()
isogs = [Ew.isogeny(f) for f in [x**2+a/(1+2*i), x**2+a/(1-2*i)]]
[isog.set_post_isomorphism(isog.codomain().isomorphism_to(E)) for isog in isogs]
isogs = [isog.codomain().isomorphism_to(E) * isog for isog in isogs]
# Type 2: if 5 is a square we have up to 4 (non-endomorphism) isogenies
if square5:
betas = sorted((x**4+20*a*x**2-80*a**2).roots(multiplicities=False))
gammas = [(beta**2-2*a)/6 for beta in betas]
isogs += [Ew.isogeny(x**2+beta*x+gamma, model=model) for beta,gamma in zip(betas,gammas)]
[isog.set_pre_isomorphism(iso) for isog in isogs]
isogs = [isog * iso for isog in isogs]
return isogs

def isogenies_7_0(E, minimal_models=True):
Expand Down Expand Up @@ -1026,8 +1026,7 @@ def isogenies_7_0(E, minimal_models=True):
kers = [7*x-(2+6*t) for t in ts]
kers = [k(x**3/a).monic() for k in kers]
isogs = [Ew.isogeny(k,model=model) for k in kers]
if isogs:
[endo.set_post_isomorphism(endo.codomain().isomorphism_to(E)) for endo in isogs]
isogs = [endo.codomain().isomorphism_to(E) * endo for endo in isogs]

# we may have up to 6 other isogenies:
ts = (x**2-21).roots(multiplicities=False)
Expand All @@ -1038,7 +1037,7 @@ def isogenies_7_0(E, minimal_models=True):
kers = [ker(x/s).monic() for s in ss]
isogs += [Ew.isogeny(k, model=model) for k in kers]

[isog.set_pre_isomorphism(iso) for isog in isogs]
isogs = [isog * iso for isog in isogs]
return isogs

def isogenies_7_1728(E, minimal_models=True):
Expand Down Expand Up @@ -1127,7 +1126,7 @@ def isogenies_7_1728(E, minimal_models=True):

kers = [ker(x/s) for s in ss]
isogs += [Ew.isogeny(k.monic(), model=model) for k in kers]
[isog.set_pre_isomorphism(iso) for isog in isogs]
isogs = [isog * iso for isog in isogs]
return isogs

def isogenies_13_0(E, minimal_models=True):
Expand Down Expand Up @@ -1236,8 +1235,7 @@ def isogenies_13_0(E, minimal_models=True):
kers = [13*x**2 + (78*t + 26)*x + 24*t + 40 for t in ts]
kers = [k(x**3/a).monic() for k in kers]
isogs = [Ew.isogeny(k,model=model) for k in kers]
if isogs:
[endo.set_post_isomorphism(endo.codomain().isomorphism_to(E)) for endo in isogs]
isogs = [endo.codomain().isomorphism_to(E) * endo for endo in isogs]

# we may have up to 12 other isogenies:
ts = sorted((x**4 + 7*x**3 + 20*x**2 + 19*x + 1).roots(multiplicities=False))
Expand All @@ -1253,7 +1251,7 @@ def isogenies_13_0(E, minimal_models=True):
kers = [ker(x/s).monic() for s in ss]
isogs += [Ew.isogeny(k, model=model) for k in kers]

[isog.set_pre_isomorphism(iso) for isog in isogs]
isogs = [isog * iso for isog in isogs]

return isogs

Expand Down Expand Up @@ -1355,8 +1353,7 @@ def isogenies_13_1728(E, minimal_models=True):
kers = [13*x**3 + (-26*i - 13)*x**2 + (-52*i - 13)*x - 2*i - 3 for i in ts]
kers = [k(x**2/a).monic() for k in kers]
isogs = [Ew.isogeny(k,model=model) for k in kers]
if isogs:
[endo.set_post_isomorphism(endo.codomain().isomorphism_to(E)) for endo in isogs]
isogs = [endo.codomain().isomorphism_to(E) * endo for endo in isogs]

# we may have up to 12 other isogenies:

Expand All @@ -1380,7 +1377,7 @@ def isogenies_13_1728(E, minimal_models=True):
kers = [ker(x/s).monic() for s in ss]
isogs += [Ew.isogeny(k, model=model) for k in kers]

[isog.set_pre_isomorphism(iso) for isog in isogs]
isogs = [isog * iso for isog in isogs]

return isogs

Expand Down

0 comments on commit 69a15a2

Please sign in to comment.