diff --git a/src/sage/schemes/affine/affine_homset.py b/src/sage/schemes/affine/affine_homset.py index b7acc9689fb..40df2847167 100644 --- a/src/sage/schemes/affine/affine_homset.py +++ b/src/sage/schemes/affine/affine_homset.py @@ -1,5 +1,5 @@ r""" -Set of homomorphisms between two affine schemes. +Set of homomorphisms between two affine schemes For schemes `X` and `Y`, this module implements the set of morphisms `Hom(X,Y)`. This is done by :class:`SchemeHomset_generic`. @@ -38,7 +38,6 @@ from sage.categories.number_fields import NumberFields from sage.rings.finite_rings.constructor import is_FiniteField from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing - import sage.schemes.generic.homset #******************************************************************* diff --git a/src/sage/schemes/affine/affine_morphism.py b/src/sage/schemes/affine/affine_morphism.py index bdae7bf4bdb..9e17096c8fc 100644 --- a/src/sage/schemes/affine/affine_morphism.py +++ b/src/sage/schemes/affine/affine_morphism.py @@ -1,5 +1,5 @@ r""" -Morphisms on affine varieties. +Morphisms on affine varieties A morphism of schemes determined by rational functions that define what the morphism does on points in the ambient affine space. @@ -30,23 +30,23 @@ from sage.calculus.functions import jacobian -from sage.categories.homset import Hom -from sage.matrix.constructor import matrix, identity_matrix -from sage.misc.cachefunc import cached_method -from sage.misc.all import prod -from sage.rings.all import Integer -from sage.arith.all import lcm, gcd -from sage.rings.complex_field import ComplexField +from sage.categories.homset import Hom +from sage.matrix.constructor import matrix, identity_matrix +from sage.misc.cachefunc import cached_method +from sage.misc.all import prod +from sage.rings.all import Integer +from sage.arith.all import lcm, gcd +from sage.rings.complex_field import ComplexField from sage.rings.finite_rings.constructor import GF, is_PrimeFiniteField -from sage.rings.fraction_field import FractionField +from sage.rings.fraction_field import FractionField from sage.rings.fraction_field_element import FractionFieldElement -from sage.rings.integer_ring import ZZ +from sage.rings.integer_ring import ZZ from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing -from sage.rings.quotient_ring import QuotientRing_generic -from sage.rings.real_mpfr import RealField +from sage.rings.quotient_ring import QuotientRing_generic +from sage.rings.real_mpfr import RealField from sage.schemes.generic.morphism import SchemeMorphism_polynomial -from sage.misc.lazy_attribute import lazy_attribute -from sage.ext.fast_callable import fast_callable +from sage.misc.lazy_attribute import lazy_attribute +from sage.ext.fast_callable import fast_callable import sys class SchemeMorphism_polynomial_affine_space(SchemeMorphism_polynomial): @@ -173,7 +173,7 @@ def __call__(self, x, check=True): except (TypeError, NotImplementedError): raise TypeError("%s fails to convert into the map's domain %s, but a `pushforward` method is not properly implemented"%(x, self.domain())) elif self.domain() != x.codomain(): - raise TypeError("%s fails to convert into the map's domain %s, but a `pushforward` method is not properly implemented"%(x, self.domain())) + raise TypeError("%s fails to convert into the map's domain %s,but a `pushforward` method is not properly implemented"%(x, self.domain())) # Passes the array of args to _fast_eval P = self._fast_eval(x._coords) @@ -189,7 +189,7 @@ def __eq__(self, right): OUTPUT: - - Boolean - True if ``affine map`` and ``right`` define the same affine map. False otherwise. + - Boolean - True if the two affine maps defined the same map. EXAMPLES:: @@ -226,7 +226,7 @@ def __ne__(self, right): OUTPUT: - - Boolean -- True if ``affine map`` and ``right`` define different affine maps. False otherwise. + - Boolean -- True if the two affine maps defined the same map. EXAMPLES:: @@ -327,7 +327,8 @@ def _fast_eval(self, x): P = [] for i in range(len(self._fastpolys[0])): - # Check if denominator is the identity; if not, then must append the fraction evaluated at the point + # Check if denominator is the identity; + #if not, then must append the fraction evaluated at the point if self._fastpolys[1][i] is R.one(): P.append(self._fastpolys[0][i](*x)) else: @@ -344,8 +345,8 @@ def homogenize(self, n): INPUT: - - ``n`` -- a tuple of nonnegative integers. If ``n`` is an integer, then the two values of - the tuple are assumed to be the same. + - ``n`` -- a tuple of nonnegative integers. If ``n`` is an integer, + then the two values of the tuple are assumed to be the same. OUTPUT: @@ -355,7 +356,7 @@ def homogenize(self, n): sage: A. = AffineSpace(ZZ, 2) sage: H = Hom(A, A) - sage: f = H([(x^2-2)/x^5,y^2]) + sage: f = H([(x^2-2)/x^5, y^2]) sage: f.homogenize(2) Scheme endomorphism of Projective Space of dimension 2 over Integer Ring Defn: Defined on coordinates by sending (x0 : x1 : x2) to @@ -380,7 +381,8 @@ def homogenize(self, n): sage: H = Hom(X, X) sage: f = H([9*y^2, 3*y]) sage: f.homogenize(2) - Scheme endomorphism of Closed subscheme of Projective Space of dimension 2 over Integer Ring defined by: + Scheme endomorphism of Closed subscheme of Projective Space + of dimension 2 over Integer Ring defined by: -x1^2 + x0*x2 Defn: Defined on coordinates by sending (x0 : x1 : x2) to (9*x0*x2 : 3*x1*x2 : x2^2) @@ -436,7 +438,8 @@ def homogenize(self, n): sage: A. = AffineSpace(K, 1) sage: f = Hom(A, A)([x^2 + c]) sage: f.homogenize(1) - Scheme endomorphism of Projective Space of dimension 1 over Rational function field in c over Rational Field + Scheme endomorphism of Projective Space of + dimension 1 over Rational function field in c over Rational Field Defn: Defined on coordinates by sending (x0 : x1) to (x0^2 + c*x1^2 : x1^2) """ @@ -498,7 +501,8 @@ def dynatomic_polynomial(self, period): INPUT: - - ``period`` -- a positive integer or a list/tuple `[m,n]` where `m` is the preperiod and `n` is the period. + - ``period`` -- a positive integer or a list/tuple `[m,n]`, + where `m` is the preperiod and `n` is the period. OUTPUT: @@ -580,7 +584,7 @@ def dynatomic_polynomial(self, period): def nth_iterate_map(self, n): r""" - This function returns the nth iterate of the map. + This function returns the ``n``th iterate of the map. ALGORITHM: @@ -655,16 +659,17 @@ def nth_iterate_map(self, n): def nth_iterate(self, P, n): r""" - Returns the nth iterate of the point ``P`` by this map. + Returns the ``n``th iterate of the point ``P`` by this map. INPUT: - - ``P`` -- a point in the maps domain. + - ``P`` -- a point in the map's domain. + - ``n`` -- a positive integer. OUTPUT: - - a point in the maps codomain. + - a point in the map's codomain. EXAMPLES:: @@ -700,12 +705,12 @@ def orbit(self, P, n): Returns the orbit of ``P`` by the map. If `n` is an integer it returns `[P,self(P),\ldots,self^n(P)]`. - If `n` is a list or tuple `n=[m,k]` it returns `[self^m(P),\ldots,self^k(P)]`. INPUT: - ``P`` -- a point in the map domain. + - ``n`` -- a non-negative integer or list or tuple of two non-negative integers. OUTPUT: @@ -740,7 +745,7 @@ def orbit(self, P, n): :: sage: R. = PolynomialRing(QQ) - sage: A.= AffineSpace(FractionField(R), 2) + sage: A. = AffineSpace(FractionField(R), 2) sage: H = Hom(A, A) sage: f = H([(x-t*y^2)/x, t*x*y]) sage: f.orbit(A(1, t), 3) @@ -750,9 +755,10 @@ def orbit(self, P, n): """ return(P.orbit(self, n)) - def global_height(self,prec=None): + def global_height(self, prec=None): r""" - Returns the maximum of the heights of the coefficients in any of the coordinate functions of the affine morphism. + Returns the maximum of the heights of the coefficients in any + of the coordinate functions of the affine morphism. INPUT: @@ -767,7 +773,7 @@ def global_height(self,prec=None): sage: A. = AffineSpace(QQ, 1) sage: H = Hom(A, A) - sage: f = H([1/1331*x^2+4000]); + sage: f = H([1/1331*x^2 + 4000]); sage: f.global_height() 8.29404964010203 @@ -777,25 +783,18 @@ def global_height(self,prec=None): sage: k. = NumberField(x^2 + 5) sage: A. = AffineSpace(k, 2) sage: H = Hom(A, A) - sage: f = H([13*w*x^2+4*y, 1/w*y^2]); + sage: f = H([13*w*x^2 + 4*y, 1/w*y^2]); sage: f.global_height(prec=100) 3.3696683136785869233538671082 - .. TODO:: + :: - Add heights to integer.pyx and remove special case. + sage: A. = AffineSpace(ZZ, 1) + sage: H = Hom(A, A) + sage: f = H([7*x^2 + 1513]); + sage: f.global_height() + 7.32184971378836 """ - if self.domain().base_ring() == ZZ: - if prec is None: - R = RealField() - else: - R = RealField(prec) - H = R(0) - for i in range(self.domain().ambient_space().dimension_relative()): - C = self[i].coefficients() - h = max([c.abs() for c in C]) - H = max(H, R(h).log()) - return(H) H=0 for i in range(self.domain().ambient_space().dimension_relative()): C = self[i].coefficients() @@ -810,8 +809,8 @@ def jacobian (self): r""" Returns the Jacobian matrix of partial derivitive of this map. - The ``(i, j)`` entry of the Jacobian matrix is the partial derivative - ``diff(functions[i], variables[j])``. + The `(i, j)` entry of the Jacobian matrix is the partial derivative + `diff(functions[i], variables[j])`. OUTPUT: @@ -821,7 +820,7 @@ def jacobian (self): sage: A. = AffineSpace(QQ, 1) sage: H = End(A) - sage: f = H([z^2-3/4]) + sage: f = H([z^2 - 3/4]) sage: f.jacobian() [2*z] @@ -866,7 +865,7 @@ def multiplier(self, P, n, check=True): OUTPUT: - a square matrix of size ``self.codomain().dimension_relative()`` in - the ``base_ring`` of the map. + the ``base_ring`` of the map. EXAMPLES:: @@ -993,12 +992,14 @@ class SchemeMorphism_polynomial_affine_space_finite_field(SchemeMorphism_polynom def orbit_structure(self, P): r""" - Every point is preperiodic over a finite field. This function returns the pair `[m,n]` where `m` is the + Every point is preperiodic over a finite field. + + This function returns the pair `[m,n]` where `m` is the preperiod and `n` is the period of the point ``P`` by this map. INPUT: - - ``P`` -- a point in the maps domain. + - ``P`` -- a point in the map's domain. OUTPUT: @@ -1024,7 +1025,7 @@ def orbit_structure(self, P): def _fast_eval(self, x): """ - Evaluate affine morphism at point described by x. + Evaluate affine morphism at point described by ``x``. EXAMPLES:: @@ -1063,12 +1064,12 @@ def _fast_eval(self, x): def cyclegraph(self): r""" - Returns digraph of all orbits of this morphism mod `p`. For subschemes, only points on the subscheme whose - image are also on the subscheme are in the digraph. + Returns digraph of all orbits of this morphism mod `p`. - OUTPUT: + For subschemes, only points on the subscheme whose + image are also on the subscheme are in the digraph. - - a digraph. + OUTPUT: A digraph. EXAMPLES:: diff --git a/src/sage/schemes/affine/affine_point.py b/src/sage/schemes/affine/affine_point.py index 2e29b54653f..f7152546ef5 100644 --- a/src/sage/schemes/affine/affine_point.py +++ b/src/sage/schemes/affine/affine_point.py @@ -1,5 +1,5 @@ r""" -Points on affine varieties. +Points on affine varieties Scheme morphism for points on affine varieties. @@ -29,15 +29,15 @@ # http://www.gnu.org/licenses/ #***************************************************************************** -from copy import copy +from copy import copy from sage.categories.number_fields import NumberFields _NumberFields = NumberFields() -from sage.rings.integer_ring import ZZ +from sage.rings.integer_ring import ZZ from sage.rings.number_field.order import is_NumberFieldOrder -from sage.rings.rational_field import QQ -from sage.rings.real_mpfr import RealField +from sage.rings.rational_field import QQ +from sage.rings.real_mpfr import RealField from sage.schemes.generic.morphism import (SchemeMorphism_point, SchemeMorphism, is_SchemeMorphism) -from sage.structure.sequence import Sequence +from sage.structure.sequence import Sequence ############################################################################ # Rational points on schemes, which we view as morphisms determined @@ -99,6 +99,7 @@ def nth_iterate(self, f, n): INPUT: - ``f`` -- a :class:`SchemeMorphism_polynomial` with ``self`` if ``f.domain()``. + - ``n`` -- a positive integer. OUTPUT: @@ -136,13 +137,15 @@ def nth_iterate(self, f, n): def orbit(self, f, N): r""" - Returns the orbit of the point by `f`. If `n` is an integer it returns `[self,f(self), \ldots, f^{n}(self)]`. + Returns the orbit of the point by `f`. If `n` is an integer it returns + `[self,f(self), \ldots, f^{n}(self)]`. If `n` is a list or tuple `n=[m, k]` it returns `[f^{m}(self), \ldots, f^{k}(self)]`. INPUT: - ``f`` -- a :class:`SchemeMorphism_polynomial` with the point in ``f.domain()``. + - ``n`` -- a non-negative integer or list or tuple of two non-negative integers. OUTPUT: @@ -174,7 +177,7 @@ def orbit(self, f, N): sage: X(9, 3).orbit(f, (0, 4)) [(9, 3), (81, 9), (729, 27), (6561, 81), (59049, 243)] """ - Q=copy(self) + Q = self if isinstance(N, list) or isinstance(N, tuple): Bounds = list(N) else: @@ -238,7 +241,7 @@ def global_height(self, prec=None): if self.domain().base_ring() in _NumberFields or is_NumberFieldOrder(self.domain().base_ring()): return(max([self[i].global_height(prec) for i in range(self.codomain().ambient_space().dimension_relative())])) else: - raise NotImplementedError("must be over a Numberfield or a Numberfield Order") + raise NotImplementedError("must be over a number field or a number field Order") def homogenize(self, n): r""" @@ -290,7 +293,7 @@ def weil_restriction(self): the equivalent point on the Weil restriction of its codomain. - OUTPUT: Scheme point on the Weil restriction of the codomain of ``self``. + OUTPUT: Scheme point on the Weil restriction of the codomain of this point. EXAMPLES:: @@ -352,9 +355,7 @@ def __hash__(self): r""" Returns the integer hash of the point. - OUTPUT: - - - integer. + OUTPUT: integer. EXAMPLES:: @@ -387,7 +388,9 @@ def __hash__(self): def orbit_structure(self, f): r""" - Every point is preperiodic over a finite field. This function returns the pair `[m, n]` where `m` is the + Every point is preperiodic over a finite field. + + This function returns the pair `[m, n]` where `m` is the preperiod and `n` is the period of the point by ``f``. INPUT: @@ -402,7 +405,7 @@ def orbit_structure(self, f): sage: P. = AffineSpace(GF(5), 3) sage: H = Hom(P, P) - sage: f = H([x^2 + y^2, y^2, z^2 + y * z]) + sage: f = H([x^2 + y^2, y^2, z^2 + y*z]) sage: P(1, 1, 1).orbit_structure(f) [0, 6] @@ -419,17 +422,16 @@ def orbit_structure(self, f): sage: P. = AffineSpace(GF(13), 2) sage: H = Hom(P, P) - sage: f = H([x^2 - y^2,y^2]) + sage: f = H([x^2 - y^2, y^2]) sage: P(3, 4).orbit_structure(f) [2, 6] """ Orbit = [] index = 1 - P = copy(self) - F = copy(f) + P = self while not P in Orbit: Orbit.append(P) - P = F(P) + P = f(P) index += 1 I = Orbit.index(P) return([I, index-I-1]) diff --git a/src/sage/schemes/affine/affine_rational_point.py b/src/sage/schemes/affine/affine_rational_point.py index a585648985e..93091c65bf7 100644 --- a/src/sage/schemes/affine/affine_rational_point.py +++ b/src/sage/schemes/affine/affine_rational_point.py @@ -1,5 +1,5 @@ r""" -Enumeration of rational points on affine schemes. +Enumeration of rational points on affine schemes Naive algorithms for enumerating rational points over `\QQ` or finite fields over for general schemes. diff --git a/src/sage/schemes/affine/affine_space.py b/src/sage/schemes/affine/affine_space.py index df72e9ea7d0..bc5d23cc618 100644 --- a/src/sage/schemes/affine/affine_space.py +++ b/src/sage/schemes/affine/affine_space.py @@ -1,5 +1,5 @@ """ -Affine `n` space over a ring. +Affine `n` space over a ring """ #***************************************************************************** @@ -10,23 +10,16 @@ # http://www.gnu.org/licenses/ #***************************************************************************** -from sage.rings.all import ( - PolynomialRing, - ZZ, - Integer) - +from sage.rings.all import (PolynomialRing, ZZ, Integer) from sage.rings.ring import is_Ring from sage.rings.rational_field import is_RationalField from sage.rings.polynomial.multi_polynomial_ring import is_MPolynomialRing from sage.rings.finite_rings.constructor import is_FiniteField - from sage.categories.fields import Fields _Fields = Fields() from sage.categories.number_fields import NumberFields - from sage.misc.all import latex from sage.structure.category_object import normalize_names - from sage.schemes.generic.scheme import AffineScheme from sage.schemes.generic.ambient_space import AmbientSpace from sage.schemes.affine.affine_homset import SchemeHomset_points_affine @@ -41,7 +34,7 @@ def is_AffineSpace(x): r""" - Returns True if x is an affine space. + Returns True if ``x`` is an affine space. EXAMPLES:: @@ -57,7 +50,7 @@ def is_AffineSpace(x): def AffineSpace(n, R=None, names='x'): r""" - Return affine space of dimension `n` over the ring `R`. + Return affine space of dimension ``n`` over the ring ``R``. EXAMPLES: @@ -220,8 +213,8 @@ def ngens(self): def rational_points(self, F=None): """ - Return the list of `F`-rational points on the affine space self, - where `F` is a given finite field, or the base ring of self. + Return the list of ``F``-rational points on the affine space self, + where ``F`` is a given finite field, or the base ring of self. EXAMPLES:: @@ -397,9 +390,9 @@ def _repr_generic_point(self, polys=None): def _latex_generic_point(self, v=None): """ Return a LaTeX representation of the generic point - corresponding to the list of polys on this affine space. + corresponding to the list of polys ``v`` on this affine space. - If polys is None, the representation of the generic point of + If ``v`` is None, the representation of the generic point of the affine space is returned. EXAMPLES:: @@ -416,7 +409,7 @@ def _latex_generic_point(self, v=None): def _check_satisfies_equations(self, v): """ - Return True if `v` defines a point on the scheme self; raise a + Return True if ``v`` defines a point on the scheme self; raise a TypeError otherwise. EXAMPLES:: @@ -454,7 +447,7 @@ def _check_satisfies_equations(self, v): def __pow__(self, m): """ - Return the Cartesian power of this space + Return the Cartesian power of this space. INPUT: @@ -487,7 +480,7 @@ def __pow__(self, m): def change_ring(self, R): r""" - Return an affine space over ring `R` and otherwise the same as this space. + Return an affine space over ring ``R`` and otherwise the same as this space. INPUT: @@ -522,12 +515,14 @@ def coordinate_ring(self): sage: R = AffineSpace(2, GF(9,'alpha'), 'z').coordinate_ring(); R Multivariate Polynomial Ring in z0, z1 over Finite Field in alpha of size 3^2 sage: AffineSpace(3, R, 'x').coordinate_ring() - Multivariate Polynomial Ring in x0, x1, x2 over Multivariate Polynomial Ring in z0, z1 over Finite Field in alpha of size 3^2 + Multivariate Polynomial Ring in x0, x1, x2 over Multivariate Polynomial Ring + in z0, z1 over Finite Field in alpha of size 3^2 """ try: return self._coordinate_ring except AttributeError: - self._coordinate_ring = PolynomialRing(self.base_ring(), self.dimension_relative(), names=self.variable_names()) + self._coordinate_ring = PolynomialRing(self.base_ring(), + self.dimension_relative(), names=self.variable_names()) return self._coordinate_ring def _validate(self, polynomials): @@ -643,7 +638,7 @@ def projective_embedding(self, i=None, PP=None): def subscheme(self, X): """ - Return the closed subscheme defined by X. + Return the closed subscheme defined by ``X``. INPUT: @@ -710,7 +705,7 @@ def _an_element_(self): class AffineSpace_field(AffineSpace_generic): def _point(self, *args, **kwds): """ - Constructs a point. + Construct a point. For internal use only. See :mod:`morphism` for details. @@ -741,11 +736,13 @@ def _morphism(self, *args, **kwds): def points_of_bounded_height(self,bound): r""" - Returns an iterator of the points in self of absolute height of at most the given bound. + Returns an iterator of the points in this affine space of + absolute height of at most the given bound. - Bound check - is strict for the rational field. Requires self to be affine space over a number field. Uses the - Doyle-Krumm algorithm for computing algebraic numbers up to a given height [Doyle-Krumm]_. + Bound check is strict for the rational field. + Requires this space to be affine space over a number field. Uses the + Doyle-Krumm algorithm for computing algebraic numbers up + to a given height [Doyle-Krumm]_. INPUT: @@ -811,7 +808,9 @@ def points_of_bounded_height(self,bound): def weil_restriction(self): r""" Compute the Weil restriction of this affine space over some extension - field. If the field is a finite field, then this computes + field. + + If the field is a finite field, then this computes the Weil restriction to the prime subfield. OUTPUT: Affine space of dimension ``d * self.dimension_relative()``