Skip to content

Commit

Permalink
Trac #34644: minor details in schemes
Browse files Browse the repository at this point in the history
some about E241 and E502

URL: https://trac.sagemath.org/34644
Reported by: chapoton
Ticket author(s): Frédéric Chapoton
Reviewer(s): Travis Scrimshaw
  • Loading branch information
Release Manager committed Oct 11, 2022
2 parents 3384309 + 9410446 commit 1a1d67d
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 74 deletions.
18 changes: 9 additions & 9 deletions src/sage/schemes/elliptic_curves/ell_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1918,9 +1918,9 @@ def division_polynomial(self, m, x=None, two_torsion_multiplicity=2, force_evalu
and x.lift().base_ring() is self.base_ring():
d = x.parent().modulus().degree()
evaluate = m < 220 or \
(d < 10 and m < 420) or (d < 15 and m < 340) or \
(d < 30 and m < 280) or (d < 100 and m < 250) or \
m <= min(250, d)
(d < 10 and m < 420) or (d < 15 and m < 340) or \
(d < 30 and m < 280) or (d < 100 and m < 250) or \
m <= min(250, d)

# Check if we should (attempt to) compute the result by simply
# evaluating a cached polynomial at the given input.
Expand Down Expand Up @@ -2849,16 +2849,16 @@ def montgomery_model(self, twisted=False, morphism=False):
return E, self.isomorphism_to(E)
return E

P2, (x,y,z) = self.ambient_space().objgens()
P2, (x, y, z) = self.ambient_space().objgens()
f = B * y**2*z - x * (x * (x + A*z) + z**2)
C = plane_curve.ProjectivePlaneCurve(P2, f)

if not morphism:
return C

t = ~(B * s).sqrt()
iso_maps = (x - r * z, t * y , s * z)
inv_maps = (x * s + r * z, s * y/t, z)
iso_maps = (x - r * z, t * y, s * z)
inv_maps = (x * s + r * z, s * y / t, z)

w = self.isomorphism_to(Ew)
wmap, winv = w.rational_maps(), (~w).rational_maps()
Expand All @@ -2868,7 +2868,7 @@ def montgomery_model(self, twisted=False, morphism=False):
inv = [f(*inv_maps) for f in winv]

from sage.schemes.elliptic_curves.weierstrass_transform \
import WeierstrassTransformationWithInverse as WTI
import WeierstrassTransformationWithInverse as WTI
iso = WTI(self, C, iso, 1, inv, s**-3)
return C, iso

Expand Down Expand Up @@ -3194,7 +3194,7 @@ def _p_primary_torsion_basis(self, p, m=None):
k = 1
log_order = 2
if m <= log_order:
return [[P1,1],[P2,1]]
return [[P1, 1], [P2, 1]]

pts1 = P1.division_points(p)
pts2 = P2.division_points(p)
Expand Down Expand Up @@ -3255,7 +3255,7 @@ def _p_primary_torsion_basis(self, p, m=None):
return [[P1, n], [P2, k]]
pts = P1.division_points(p)
if not pts:
for Q in generic.multiples(P2,p-1,P1+P2,operation='+'):
for Q in generic.multiples(P2, p-1, P1+P2, operation='+'):
# Q runs through P1+a*P2 for a=1,2,...,p-1
pts = Q.division_points(p)
if pts:
Expand Down
37 changes: 19 additions & 18 deletions src/sage/schemes/elliptic_curves/heegner.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@
from sage.modular.modsym.p1list import P1List


##################################################################################
###############################################################################
#
# The exported functions, which are in most cases enough to get the
# user going working with Heegner points:
#
# heegner_points -- all of them with given level, discriminant, conductor
# heegner_point -- a specific one
#
##################################################################################
###############################################################################

def heegner_points(N, D=None, c=None):
"""
Expand All @@ -135,11 +135,11 @@ def heegner_points(N, D=None, c=None):
INPUT:
- `N` -- level (positive integer)
- `N` -- level (positive integer)
- `D` -- discriminant (negative integer)
- `D` -- discriminant (negative integer)
- `c` -- conductor (positive integer)
- `c` -- conductor (positive integer)
EXAMPLES::
Expand All @@ -155,9 +155,10 @@ def heegner_points(N, D=None, c=None):
if D is not None and c is None:
return HeegnerPoints_level_disc(N, D)
if D is not None and c is not None:
return HeegnerPoints_level_disc_cond(N,D,c)
return HeegnerPoints_level_disc_cond(N, D, c)
raise TypeError


def heegner_point(N, D=None, c=1):
"""
Return a specific Heegner point of level `N` with given
Expand All @@ -167,11 +168,11 @@ def heegner_point(N, D=None, c=1):
INPUT:
- `N` -- level (positive integer)
- `N` -- level (positive integer)
- `D` -- discriminant (optional: default first valid `D`)
- `D` -- discriminant (optional: default first valid `D`)
- `c` -- conductor (positive integer, optional, default: 1)
- `c` -- conductor (positive integer, optional, default: 1)
EXAMPLES::
Expand All @@ -185,20 +186,20 @@ def heegner_point(N, D=None, c=1):
Heegner point 1/778*sqrt(-20) - 165/389 of discriminant -20 on X_0(389)
"""
if D is not None:
return heegner_points(N,D,c)[0]
return heegner_points(N, D, c)[0]
H = heegner_points(N)
D = H.discriminants(1)[0]
return heegner_points(N,D,c)[0]
return heegner_points(N, D, c)[0]


##################################################################################
###############################################################################
#
# Ring class fields, represented as abstract objects. These do not
# derive from number fields, since we do not need to work with their
# elements, and explicitly representing them as number fields would be
# far too difficult.
#
##################################################################################
###############################################################################

class RingClassField(SageObject):
"""
Expand Down Expand Up @@ -352,9 +353,8 @@ def _repr_(self):
"""
c = self.__c
if c == 1:
return "Hilbert class field of QQ[sqrt(%s)]"%self.__D
else:
return "Ring class field extension of QQ[sqrt(%s)] of conductor %s"%(self.__D, self.__c)
return "Hilbert class field of QQ[sqrt(%s)]" % self.__D
return "Ring class field extension of QQ[sqrt(%s)] of conductor %s" % (self.__D, self.__c)

@cached_method
def degree_over_K(self):
Expand Down Expand Up @@ -6533,7 +6533,8 @@ def heegner_point_height(self, D, prec=2, check_rank=True):
return IR(alpha-MIN_ERR,alpha+MIN_ERR) * IR(LE1-err_E,LE1+err_E) * IR(LF1-err_F,LF1+err_F)


def heegner_index(self, D, min_p=2, prec=5, descent_second_limit=12, verbose_mwrank=False, check_rank=True):
def heegner_index(self, D, min_p=2, prec=5, descent_second_limit=12,
verbose_mwrank=False, check_rank=True):
r"""
Return an interval that contains the index of the Heegner
point `y_K` in the group of `K`-rational points modulo torsion
Expand Down Expand Up @@ -6745,7 +6746,7 @@ def _adjust_heegner_index(self, a):
return a.sqrt()


def heegner_index_bound(self, D=0, prec=5, max_height=None):
def heegner_index_bound(self, D=0, prec=5, max_height=None):
r"""
Assume ``self`` has rank 0.
Expand Down
38 changes: 18 additions & 20 deletions src/sage/schemes/hyperelliptic_curves/constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
- David Kohel (2006): initial version
- Anna Somoza (2019-04): dynamic class creation
"""

#*****************************************************************************
# ****************************************************************************
# Copyright (C) 2006 David Kohel <kohel@maths.usyd.edu>
# 2019 Anna Somoza <anna.somoza.henares@gmail.com>
# Distributed under the terms of the GNU General Public License (GPL)
# http://www.gnu.org/licenses/
#*****************************************************************************
# https://www.gnu.org/licenses/
# ****************************************************************************

from sage.schemes.projective.projective_space import ProjectiveSpace

Expand All @@ -31,6 +29,7 @@

from sage.structure.dynamic_class import dynamic_class


def HyperellipticCurve(f, h=0, names=None, PP=None, check_squarefree=True):
r"""
Returns the hyperelliptic curve `y^2 + h y = f`, for
Expand Down Expand Up @@ -216,40 +215,39 @@ def HyperellipticCurve(f, h=0, names=None, PP=None, check_squarefree=True):
if P(2) == 0:
# characteristic 2
if h == 0:
raise ValueError("In characteristic 2, argument h (= %s) must be non-zero."%h)
raise ValueError("In characteristic 2, argument h (= %s) must be non-zero." % h)
if h[g+1] == 0 and f[2*g+1]**2 == f[2*g+2]*h[g]**2:
raise ValueError("Not a hyperelliptic curve: " \
"highly singular at infinity.")
raise ValueError("Not a hyperelliptic curve: "
"highly singular at infinity.")
should_be_coprime = [h, f*h.derivative()**2+f.derivative()**2]
else:
# characteristic not 2
if not F.degree() in [2*g+1, 2*g+2]:
raise ValueError("Not a hyperelliptic curve: " \
"highly singular at infinity.")
raise ValueError("Not a hyperelliptic curve: "
"highly singular at infinity.")
should_be_coprime = [F, F.derivative()]
try:
smooth = should_be_coprime[0].gcd(should_be_coprime[1]).degree()==0
smooth = should_be_coprime[0].gcd(should_be_coprime[1]).degree() == 0
except (AttributeError, NotImplementedError, TypeError):
try:
smooth = should_be_coprime[0].resultant(should_be_coprime[1])!=0
smooth = should_be_coprime[0].resultant(should_be_coprime[1]) != 0
except (AttributeError, NotImplementedError, TypeError):
raise NotImplementedError("Cannot determine whether " \
"polynomials %s have a common root. Use " \
"check_squarefree=False to skip this check." % \
raise NotImplementedError("Cannot determine whether "
"polynomials %s have a common root. Use "
"check_squarefree=False to skip this check." %
should_be_coprime)
if not smooth:
raise ValueError("Not a hyperelliptic curve: " \
"singularity in the provided affine patch.")
raise ValueError("Not a hyperelliptic curve: "
"singularity in the provided affine patch.")
R = P.base_ring()
PP = ProjectiveSpace(2, R)
if names is None:
names = ["x","y"]
names = ["x", "y"]

superclass = []
cls_name = ["HyperellipticCurve"]

genus_classes = {
2 : HyperellipticCurve_g2}
genus_classes = {2: HyperellipticCurve_g2}

is_pAdicField = lambda x: isinstance(x, sage.rings.abc.pAdicField)

Expand Down
53 changes: 26 additions & 27 deletions src/sage/schemes/plane_conics/con_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from sage.categories.fields import Fields
_Fields = Fields()


class ProjectiveConic_field(ProjectivePlaneCurve_field):
r"""
Create a projective plane conic curve over a field.
Expand Down Expand Up @@ -113,10 +114,10 @@ def base_extend(self, S):
if B == S:
return self
if not S.has_coerce_map_from(B):
raise ValueError("No natural map from the base ring of self " \
raise ValueError("No natural map from the base ring of self "
"(= %s) to S (= %s)" % (self, S))
from .constructor import Conic
con = Conic([S(c) for c in self.coefficients()], \
con = Conic([S(c) for c in self.coefficients()],
self.variable_names())
if self._rational_point is not None:
pt = [S(c) for c in Sequence(self._rational_point)]
Expand Down Expand Up @@ -188,9 +189,7 @@ def derivative_matrix(self):
[1 2 1]
[1 1 0]
An example in characteristic `2`:
::
An example in characteristic `2`::
sage: P.<t> = GF(2)[]
sage: c = Conic([t, 1, t^2, 1, 1, 0]); c
Expand All @@ -203,9 +202,9 @@ def derivative_matrix(self):
[t^2 1 0]
"""
a, b, c, d, e, f = self.coefficients()
return Matrix([[ 2*a , b , c ],
[ b , 2*d , e ],
[ c , e , 2*f ]])
return Matrix([[2 * a, b, c],
[b, 2 * d, e],
[c, e, 2 * f]])

def determinant(self):
r"""
Expand Down Expand Up @@ -497,8 +496,8 @@ def has_rational_point(self, point=False,
# writing) fraction field elements are not converted automatically
# from Magma to Sage.
try:
return True, self.point( \
[B(c.Numerator().sage()/c.Denominator().sage()) for c in pt])
return True, self.point(
[B(c.Numerator().sage() / c.Denominator().sage()) for c in pt])
except (TypeError, NameError):
pass

Expand Down Expand Up @@ -539,8 +538,8 @@ def has_rational_point(self, point=False,
if point:
return ret
return ret[0]
raise NotImplementedError("has_rational_point not implemented for " \
"conics over base field %s" % B)
raise NotImplementedError("has_rational_point not implemented for "
"conics over base field %s" % B)

def has_singular_point(self, point=False):
r"""
Expand Down Expand Up @@ -693,8 +692,8 @@ def hom(self, x, Y=None):
if Y is None:
Y = im
elif not Y == im:
raise ValueError("The matrix x (= %s) does not define a " \
"map from self (= %s) to Y (= %s)" % \
raise ValueError("The matrix x (= %s) does not define a "
"map from self (= %s) to Y (= %s)" %
(x, self, Y))
x = Sequence(x*vector(self.ambient_space().gens()))
return self.Hom(Y)(x, check=False)
Expand Down Expand Up @@ -1120,12 +1119,12 @@ def rational_point(self, algorithm='default', read_cache=True):
...
ValueError: Conic Projective Conic Curve over Real Field with 53 bits of precision defined by x^2 + y^2 + z^2 has no rational points over Real Field with 53 bits of precision!
"""
bl,pt = self.has_rational_point(point=True, algorithm=algorithm,
read_cache=read_cache)
bl, pt = self.has_rational_point(point=True, algorithm=algorithm,
read_cache=read_cache)
if bl:
return pt
raise ValueError("Conic %s has no rational points over %s!" % \
(self, self.ambient_space().base_ring()))
raise ValueError("Conic %s has no rational points over %s!" %
(self, self.ambient_space().base_ring()))

def singular_point(self):
r"""
Expand All @@ -1149,8 +1148,8 @@ def singular_point(self):
"""
b = self.has_singular_point(point=True)
if not b[0]:
raise ValueError("The conic self (= %s) has no rational " \
"singular point" % self)
raise ValueError("The conic self (= %s) has no rational "
"singular point" % self)
return b[1]

def symmetric_matrix(self):
Expand All @@ -1175,13 +1174,13 @@ def symmetric_matrix(self):
a, b, c, d, e, f = self.coefficients()
if self.base_ring().characteristic() == 2:
if b == 0 and c == 0 and e == 0:
return Matrix([[a,0,0],[0,d,0],[0,0,f]])
raise ValueError("The conic self (= %s) has no symmetric matrix " \
"because the base field has characteristic 2" % \
self)
return Matrix([[ a , b/2, c/2 ],
[ b/2, d , e/2 ],
[ c/2, e/2, f ]])
return Matrix([[a, 0, 0], [0, d, 0], [0, 0, f]])
raise ValueError("The conic self (= %s) has no symmetric matrix "
"because the base field has characteristic 2" %
self)
return Matrix([[a, b / 2, c / 2],
[b / 2, d, e / 2],
[c / 2, e / 2, f]])

def upper_triangular_matrix(self):
r"""
Expand Down

0 comments on commit 1a1d67d

Please sign in to comment.