Date: Thu, 17 Jul 2014 18:34:05 -0700
Subject: [PATCH 14/16] Some minor review tweaks.
---
src/sage/schemes/generic/homset.py | 3 +--
src/sage/schemes/generic/scheme.py | 40 +++++++++++++++---------------
src/sage/schemes/generic/spec.py | 33 +++++++++++-------------
3 files changed, 36 insertions(+), 40 deletions(-)
diff --git a/src/sage/schemes/generic/homset.py b/src/sage/schemes/generic/homset.py
index 1b8871de3ef..90f41f6af9d 100644
--- a/src/sage/schemes/generic/homset.py
+++ b/src/sage/schemes/generic/homset.py
@@ -204,11 +204,10 @@ def create_object(self, version, key, **extra_args):
To: Affine Space of dimension 2 over Rational Field
"""
category = key[2]
- as_point_homset = key[3] if len(key) >= 4 else False
X = extra_args.pop('X')
Y = extra_args.pop('Y')
base_ring = extra_args.pop('base_ring')
- if as_point_homset:
+ if len(key) >= 4 and key[3]:
return Y._point_homset(X, Y, category=category, base=base_ring, **extra_args)
try:
return X._homset(X, Y, category=category, base=base_ring, **extra_args)
diff --git a/src/sage/schemes/generic/scheme.py b/src/sage/schemes/generic/scheme.py
index c43169c7b6f..7104a23a177 100644
--- a/src/sage/schemes/generic/scheme.py
+++ b/src/sage/schemes/generic/scheme.py
@@ -858,13 +858,13 @@ def __init__(self, R, S=None, category=None):
"""
from sage.categories.commutative_rings import CommutativeRings
if not R in CommutativeRings():
- raise TypeError("R (=%s) must be a commutative ring" % R)
+ raise TypeError("R (={}) must be a commutative ring".format(R))
self.__R = R
if not S is None:
if not S in CommutativeRings():
- raise TypeError("S (=%s) must be a commutative ring" % S)
+ raise TypeError("S (={}) must be a commutative ring".format(S))
if not R.has_coerce_map_from(S):
- raise ValueError("There must be a natural map S --> R, but S = %s and R = %s" % (S, R))
+ raise ValueError("There must be a natural map S --> R, but S = {} and R = {}".format(S, R))
Scheme.__init__(self, S, category=category)
def __setstate__(self, state):
@@ -893,7 +893,7 @@ def _cmp_(self, X):
INPUT:
- - ``X`` -- anything.
+ - ``X`` -- anything
OUTPUT:
@@ -958,10 +958,10 @@ def _repr_(self):
sage: Spec(PolynomialRing(QQ, 3, 'x'))._repr_()
'Spectrum of Multivariate Polynomial Ring in x0, x1, x2 over Rational Field'
"""
- return "Spectrum of %s"%self.__R
+ return "Spectrum of {}".format(self.__R)
def _latex_(self):
- """
+ r"""
Return a LaTeX representation of ``self``.
OUTPUT:
@@ -976,7 +976,7 @@ def _latex_(self):
sage: S._latex_()
'\\mathrm{Spec}(\\Bold{Z}[x_{0}, x_{1}])'
"""
- return "\\mathrm{Spec}(%s)" % self.__R._latex_()
+ return "\\mathrm{{Spec}}({})".format(self.__R._latex_())
def __call__(self, *args):
"""
@@ -987,10 +987,10 @@ def __call__(self, *args):
The argument ``x`` must be one of the following:
- a prime ideal of the coordinate ring; the output will
- be the corresponding point of X
+ be the corresponding point of `X`
- - a ring or a scheme S; the output will be the set X(S) of
- S-valued points on X
+ - a ring or a scheme `S`; the output will be the set `X(S)` of
+ `S`-valued points on `X`
EXAMPLES::
@@ -1010,6 +1010,7 @@ def __call__(self, *args):
of Multivariate Polynomial Ring in x, y, z over Rational Field
This indicates the fix of :trac:`12734`::
+
sage: S = Spec(ZZ)
sage: S(ZZ)
Set of rational points of Spectrum of Integer Ring
@@ -1074,7 +1075,7 @@ def is_noetherian(self):
OUTPUT:
- Boolean. Return True if this scheme is Noetherian.
+ Boolean. Return ``True`` if this scheme is Noetherian.
EXAMPLES::
@@ -1125,7 +1126,7 @@ def base_extend(self, R):
INPUT:
- - ``R`` -- an affine scheme or a commutative ring.
+ - ``R`` -- an affine scheme or a commutative ring
EXAMPLES::
@@ -1138,7 +1139,7 @@ def base_extend(self, R):
if R in CommutativeRings():
return AffineScheme(self.coordinate_ring().base_extend(R), self.base_ring())
if not self.base_scheme() == R.base_scheme():
- raise ValueError('The new base scheme must be a scheme over the old base scheme.')
+ raise ValueError('the new base scheme must be a scheme over the old base scheme')
return AffineScheme(self.coordinate_ring().base_extend(new_base.coordinate_ring()),
self.base_ring())
@@ -1163,13 +1164,13 @@ def hom(self, x, Y=None):
INPUT:
- ``x`` -- anything hat determines a scheme morphism. If ``x``
- is a scheme, try to determine a natural map to ``x``.
+ is a scheme, try to determine a natural map to ``x``
- - ``Y`` -- the codomain scheme (optional). If ``Y`` is not
- given, try to determine ``Y`` from context.
+ - ``Y`` -- the codomain scheme (optional); if ``Y`` is not
+ given, try to determine ``Y`` from context
- - ``check`` -- boolean (optional, default=``True``). Whether
- to check the defining data for consistency.
+ - ``check`` -- boolean (optional, default: ``True``); whether
+ to check the defining data for consistency
OUTPUT:
@@ -1192,7 +1193,7 @@ def hom(self, x, Y=None):
TESTS:
- We can construct a morphism to an affine curve (trac #7956)::
+ We can construct a morphism to an affine curve (:trac:`7956`)::
sage: S. = QQ[]
sage: A1. = AffineSpace(QQ,1)
@@ -1203,7 +1204,6 @@ def hom(self, x, Y=None):
To: Affine Curve over Rational Field defined by p - 2
Defn: Defined on coordinates by sending (r) to
(2, r)
-
"""
if is_Scheme(x):
return self.Hom(x).natural_map()
diff --git a/src/sage/schemes/generic/spec.py b/src/sage/schemes/generic/spec.py
index c23f1889048..df425020957 100644
--- a/src/sage/schemes/generic/spec.py
+++ b/src/sage/schemes/generic/spec.py
@@ -6,7 +6,6 @@
- William Stein (2006): initial implementation
- Peter Bruin (2014): rewrite Spec as a functor
-
"""
#*******************************************************************************
@@ -32,7 +31,7 @@ def Spec(R, S=None):
OUTPUT:
- - ``AffineScheme`` -- the affine scheme `\text{Spec}(R)`
+ - ``AffineScheme`` -- the affine scheme `\mathrm{Spec}(R)`
EXAMPLES::
@@ -95,8 +94,8 @@ def __init__(self, base_ring=None):
sage: SpecFunctor()
Spec functor from Category of commutative rings to Category of schemes
sage: SpecFunctor(QQ)
- Spec functor from Category of commutative rings to Category of schemes over Rational Field
-
+ Spec functor from Category of commutative rings to
+ Category of schemes over Rational Field
"""
from sage.categories.all import CommutativeAlgebras, CommutativeRings, Schemes
@@ -111,7 +110,7 @@ def __init__(self, base_ring=None):
domain = CommutativeRings()
codomain = Schemes(AffineScheme(base_ring))
else:
- raise TypeError('base (= %s) must be a commutative ring')
+ raise TypeError('base (= {}) must be a commutative ring'.format(base_ring))
self._base_ring = base_ring
super(SpecFunctor, self).__init__(domain, codomain)
@@ -119,40 +118,38 @@ def _repr_(self):
"""
Return a string representation of ``self``.
- EXAMPLE::
+ EXAMPLES::
sage: from sage.schemes.generic.spec import SpecFunctor
sage: SpecFunctor(QQ)
- Spec functor from Category of commutative rings to Category of schemes over Rational Field
-
+ Spec functor from Category of commutative rings to
+ Category of schemes over Rational Field
"""
- return 'Spec functor from %s to %s' % (self.domain(), self.codomain())
+ return 'Spec functor from {} to {}'.format(self.domain(), self.codomain())
def _latex_(self):
r"""
Return a LaTeX representation of ``self``.
- EXAMPLE::
+ EXAMPLES::
sage: from sage.schemes.generic.spec import SpecFunctor
sage: latex(SpecFunctor())
\mathrm{Spec}\colon \mathbf{CommutativeRings} \longrightarrow \mathbf{Schemes}
-
"""
- return (r'\mathrm{Spec}\colon %s \longrightarrow %s'
- % (self.domain()._latex_(), self.codomain()._latex_()))
+ return r'\mathrm{{Spec}}\colon {} \longrightarrow {}'.format(
+ self.domain()._latex_(), self.codomain()._latex_())
def _apply_functor(self, A):
"""
Apply the Spec functor to the commutative ring ``A``.
- EXAMPLE::
+ EXAMPLES::
sage: from sage.schemes.generic.spec import SpecFunctor
sage: F = SpecFunctor()
- sage: F(RR)
+ sage: F(RR) # indirect doctest
Spectrum of Real Field with 53 bits of precision
-
"""
return AffineScheme(A, self._base_ring)
@@ -160,7 +157,7 @@ def _apply_functor_to_morphism(self, f):
"""
Apply the Spec functor to the ring homomorphism ``f``.
- EXAMPLE::
+ EXAMPLES::
sage: from sage.schemes.generic.spec import SpecFunctor
sage: F = SpecFunctor(GF(7))
@@ -176,7 +173,6 @@ def _apply_functor_to_morphism(self, f):
To: Univariate Polynomial Ring in t over Finite Field of size 7
Defn: x |--> t^2
y |--> t^3
-
"""
A = f.domain()
B = f.codomain()
@@ -193,3 +189,4 @@ def _apply_functor_to_morphism(self, f):
from sage.structure.sage_object import register_unpickle_override
register_unpickle_override('sage.schemes.generic.spec', 'Spec', AffineScheme)
+
From f86c030c8e9f85dca352af3a25b636ea8b0b234e Mon Sep 17 00:00:00 2001
From: Travis Scrimshaw
Date: Thu, 17 Jul 2014 18:39:12 -0700
Subject: [PATCH 15/16] Added one other # indirect doctest.
---
src/sage/schemes/generic/spec.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/sage/schemes/generic/spec.py b/src/sage/schemes/generic/spec.py
index df425020957..51c5f928cc3 100644
--- a/src/sage/schemes/generic/spec.py
+++ b/src/sage/schemes/generic/spec.py
@@ -164,7 +164,7 @@ def _apply_functor_to_morphism(self, f):
sage: A. = GF(7)[]
sage: B. = GF(7)[]
sage: f = A.hom((t^2, t^3))
- sage: Spec(f)
+ sage: Spec(f) # indirect doctest
Affine Scheme morphism:
From: Spectrum of Univariate Polynomial Ring in t over Finite Field of size 7
To: Spectrum of Multivariate Polynomial Ring in x, y over Finite Field of size 7
From 185b49cd73907d2214401f96058e61b0eb334d8e Mon Sep 17 00:00:00 2001
From: Peter Bruin
Date: Fri, 18 Jul 2014 11:28:31 +0100
Subject: [PATCH 16/16] Trac 16158: minor formatting changes
---
src/sage/schemes/generic/homset.py | 2 +-
src/sage/schemes/generic/scheme.py | 37 +++++++++++++-----------------
src/sage/schemes/generic/spec.py | 1 -
3 files changed, 17 insertions(+), 23 deletions(-)
diff --git a/src/sage/schemes/generic/homset.py b/src/sage/schemes/generic/homset.py
index 90f41f6af9d..86547dd06db 100644
--- a/src/sage/schemes/generic/homset.py
+++ b/src/sage/schemes/generic/homset.py
@@ -207,7 +207,7 @@ def create_object(self, version, key, **extra_args):
X = extra_args.pop('X')
Y = extra_args.pop('Y')
base_ring = extra_args.pop('base_ring')
- if len(key) >= 4 and key[3]:
+ if len(key) >= 4 and key[3]: # as_point_homset=True
return Y._point_homset(X, Y, category=category, base=base_ring, **extra_args)
try:
return X._homset(X, Y, category=category, base=base_ring, **extra_args)
diff --git a/src/sage/schemes/generic/scheme.py b/src/sage/schemes/generic/scheme.py
index 7104a23a177..d2f399fe82b 100644
--- a/src/sage/schemes/generic/scheme.py
+++ b/src/sage/schemes/generic/scheme.py
@@ -340,10 +340,10 @@ def point(self, v, check=True):
INPUT:
- - ``v`` -- anything that defines a point.
+ - ``v`` -- anything that defines a point
- - ``check`` -- boolean (optional, default=``True``). Whether
- to check the defining data for consistency.
+ - ``check`` -- boolean (optional, default: ``True``); whether
+ to check the defining data for consistency
OUTPUT:
@@ -613,14 +613,14 @@ def hom(self, x, Y=None, check=True):
INPUT:
- - ``x`` -- anything hat determines a scheme morphism. If ``x``
- is a scheme, try to determine a natural map to ``x``.
+ - ``x`` -- anything that determines a scheme morphism; if
+ ``x`` is a scheme, try to determine a natural map to ``x``
- - ``Y`` -- the codomain scheme (optional). If ``Y`` is not
- given, try to determine ``Y`` from context.
+ - ``Y`` -- the codomain scheme (optional); if ``Y`` is not
+ given, try to determine ``Y`` from context
- - ``check`` -- boolean (optional, default=``True``). Whether
- to check the defining data for consistency.
+ - ``check`` -- boolean (optional, default: ``True``); whether
+ to check the defining data for consistency
OUTPUT:
@@ -648,12 +648,12 @@ def _Hom_(self, Y, category=None, check=True):
INPUT:
- - ``Y`` -- a scheme. The codomain of the Hom-set.
+ - ``Y`` -- a scheme; the codomain of the Hom-set
- - ``category`` -- a category (optional). The category of the
- Hom-set.
+ - ``category`` -- a category (optional); the category of the
+ Hom-set
- - ``check`` -- boolean (optional, default=``True``). Whether
+ - ``check`` -- boolean (optional, default: ``True``); whether
to check the defining data for consistency.
OUTPUT:
@@ -1071,11 +1071,7 @@ def coordinate_ring(self):
def is_noetherian(self):
"""
- Test whether ``self`` is Noetherian.
-
- OUTPUT:
-
- Boolean. Return ``True`` if this scheme is Noetherian.
+ Return ``True`` if ``self`` is Noetherian, ``False`` otherwise.
EXAMPLES::
@@ -1163,8 +1159,8 @@ def hom(self, x, Y=None):
INPUT:
- - ``x`` -- anything hat determines a scheme morphism. If ``x``
- is a scheme, try to determine a natural map to ``x``
+ - ``x`` -- anything that determines a scheme morphism; if
+ ``x`` is a scheme, try to determine a natural map to ``x``
- ``Y`` -- the codomain scheme (optional); if ``Y`` is not
given, try to determine ``Y`` from context
@@ -1210,4 +1206,3 @@ def hom(self, x, Y=None):
if Y is None and is_RingHomomorphism(x):
Y = AffineScheme(x.domain())
return Scheme.hom(self, x, Y)
-
diff --git a/src/sage/schemes/generic/spec.py b/src/sage/schemes/generic/spec.py
index 51c5f928cc3..2f7ddb4440c 100644
--- a/src/sage/schemes/generic/spec.py
+++ b/src/sage/schemes/generic/spec.py
@@ -189,4 +189,3 @@ def _apply_functor_to_morphism(self, f):
from sage.structure.sage_object import register_unpickle_override
register_unpickle_override('sage.schemes.generic.spec', 'Spec', AffineScheme)
-