Ticket #11599: trac_11599_reviewer.patch

File trac_11599_reviewer.patch, 16.7 KB (added by novoselt, 10 years ago)
  • sage/schemes/generic/homset.py

    # HG changeset patch
    # User Andrey Novoseltsev <novoselt@gmail.com>
    # Date 1328762167 25200
    # Node ID cf7bcab00b65280dec499db809b8f97e99c68fd4
    # Parent  63082e44a50ab10c929c35fc921b249b1ad00285
    Reviewer changes to scheme morphisms refactoring.
    
    diff --git a/sage/schemes/generic/homset.py b/sage/schemes/generic/homset.py
    a b  
    66
    77As a special case, the hom sets can also represent the points of a
    88scheme. Recall that the `K`-rational points of a scheme `X` over `k`
    9 can be identified with the set of morphisms `Spec(K) \to X`. In Sage,
     9can be identified with the set of morphisms `Spec(K) \to X`. In Sage
    1010the rational points are implemented by such scheme morphisms. This is
    1111done by :class:`SchemeHomset_points` and its subclasses.
    1212
     
    1515    You should not create the homsets manually. Instead, use the
    1616    :meth:`~sage.structure.parent.Hom` method that is inherited by all
    1717    schemes.
     18   
     19AUTHORS:
     20
     21- William Stein (2006): initial version.
     22
     23- Volker Braun (2011-08-11): significant improvement and refactoring.
    1824"""
    1925
     26
    2027#*****************************************************************************
    21 #  Copyright (C) 2006 William Stein <wstein@gmail.com>
     28#       Copyright (C) 2011 Volker Braun <vbraun.name@gmail.com>
     29#       Copyright (C) 2006 William Stein <wstein@gmail.com>
     30#
    2231#  Distributed under the terms of the GNU General Public License (GPL)
     32#  as published by the Free Software Foundation; either version 2 of
     33#  the License, or (at your option) any later version.
    2334#                  http://www.gnu.org/licenses/
    2435#*****************************************************************************
    2536
     37
    2638from sage.categories.homset import HomsetWithBase
    2739from sage.structure.factory import UniqueFactory
    2840
     
    7486        sage: A2 = AffineSpace(QQ,2)
    7587        sage: A3 = AffineSpace(QQ,3)
    7688        sage: Hom = A3.Hom(A2)
     89       
     90    The Hom sets are unique::
     91   
    7792        sage: Hom is copy(Hom)
    7893        True
    7994        sage: Hom is A3.Hom(A2)
     
    8196        sage: loads(Hom.dumps()) is Hom
    8297        True
    8398
    84     Here is a tricy point. The Hom sets are not identical if
    85     domain/codomains are isomorphic but not identiacal::
     99    Here is a tricky point. The Hom sets are not identical if
     100    domains/codomains are isomorphic but not identiacal::
    86101
    87102        sage: A3_iso = AffineSpace(QQ,3)
    88103        sage: [ A3_iso is A3, A3_iso == A3 ]
     
    101116        Integer Ring
    102117    """
    103118   
    104     def create_key_and_extra_args(self, X, Y, category=None, check=True, base=ZZ):
     119    def create_key_and_extra_args(self, X, Y, category=None, base=ZZ,
     120                                  check=True):
    105121        """
    106122        Create a key that uniquely determines the Hom set.
    107123       
     
    110126        - ``X`` -- a scheme. The domain of the morphisms.
    111127       
    112128        - ``Y`` -- a scheme. The codomain of the morphisms.
     129       
     130        - ``category`` -- a category for the Hom sets (default: schemes over
     131          given base).
    113132
    114133        - ``base`` -- a scheme or a ring. The base scheme of domain
    115134          and codomain schemes. If a ring is specified, the spectrum
    116135          of that ring will be used as base scheme.
    117136
    118         - ``check`` -- boolean (default: ``True``). 
     137        - ``check`` -- boolean (default: ``True``).
    119138
    120139        EXAMPLES::
    121140       
     
    146165            base_spec = Spec(base)
    147166            base_ring = base
    148167        else:
    149             raise ValueError('The base must be an affine scheme or a commutative ring.')
     168            raise ValueError(
     169                        'The base must be a commutative ring or its spectrum.')
    150170        if not category:
    151171            from sage.categories.schemes import Schemes
    152172            category = Schemes(base_spec)
     
    256276        EXAMPLES::
    257277
    258278            sage: A = AffineSpace(4, QQ)
    259             sage: A.structure_morphism()._repr_()
    260             'Scheme morphism:\n  From: Affine Space of dimension 4 over Rational Field\n  To:   Spectrum of Rational Field\n  Defn: Structure map'
     279            sage: print A.structure_morphism()._repr_()
     280            Scheme morphism:
     281              From: Affine Space of dimension 4 over Rational Field
     282              To:   Spectrum of Rational Field
     283              Defn: Structure map
    261284        """
    262285        s = 'Set of morphisms'
    263286        s += '\n  From: %s' % self.domain()
     
    295318
    296319        INPUT:
    297320
    298         - `x` -- a ring morphism, or a list or tuple of that define a
     321        - `x` -- a ring morphism, or a list or a tuple that define a
    299322          ring morphism.
    300323
    301324        - ``check`` -- boolean (default: ``True``) passed onto
    302           functions called by this to be more careful about input
    303           argument type checking
     325          functions called by this one to be more careful about input
     326          argument type checking.
    304327       
    305328        EXAMPLES::
    306329       
     
    487510
    488511    def value_ring(self):
    489512        """
    490         Returns `R` for a point homset `X(Spec(R))`
     513        Return `R` for a point homset `X(Spec(R))`.
    491514
    492515        OUTPUT:
    493516       
     
    500523            Rational Field
    501524        """
    502525        dom = self.domain()
    503         assert is_Spec(dom)
     526        if not is_Spec(dom):
     527            raise ValueError("value rings are defined for Spec domains only!")
    504528        return dom.coordinate_ring()
    505529
    506530
     
    583607        sage: SchemeHomset_points_affine(Spec(QQ), AffineSpace(ZZ,2))
    584608        Set of rational points of Affine Space of dimension 2 over Rational Field
    585609    """
     610   
    586611    def points(self, B=0):
    587612        r"""
    588613        Return some or all rational points of an affine scheme.
    589614
    590615        INPUT:
    591616
    592         - `B` -- integer (optional, default=0). The bound for the
     617        - ``B`` -- integer (optional, default: 0). The bound for the
    593618          height of the coordinates.
    594619
    595620        OUTPUT:
    596621
    597         - If the base ring is a finite field: All points of the scheme,
     622        - If the base ring is a finite field: all points of the scheme,
    598623          given by coordinate tuples.
    599624
    600625        - If the base ring is `\QQ` or `\ZZ`: the subset of points whose
     
    858883            sage: Hom.base_extend(QQ)
    859884            Traceback (most recent call last):
    860885            ...
    861             NotImplementedError: Abelian variety point sets not
     886            NotImplementedError: Abelian variety point sets are not
    862887            implemented as modules over rings other than ZZ.
    863888        """
    864         if not R is ZZ:
    865             raise NotImplementedError('Abelian variety point sets not implemented '
    866                                       'as modules over rings other than ZZ.')
     889        if R is not ZZ:
     890            raise NotImplementedError('Abelian variety point sets are not '
     891                            'implemented as modules over rings other than ZZ.')
    867892        return self
    868893   
    869894
  • sage/schemes/generic/morphism.py

    diff --git a/sage/schemes/generic/morphism.py b/sage/schemes/generic/morphism.py
    a b  
    99    all schemes.
    1010
    1111If you want to extend the Sage library with some new kind of scheme,
    12 your new class (say, ``myscheme``) should provide a methods
     12your new class (say, ``myscheme``) should provide a method
    1313
    14 * ``myscheme._morphism_class(*args, **kwds)`` return a morphism
    15   between to schemes in your category, usually defined via
    16   polynomials. Your point class should derive from
    17   :class:`SchemeMorphism_polynomial`. They will usually be elements of
    18   the hom set
     14* ``myscheme._morphism_class(*args, **kwds)`` returning a morphism
     15  between two schemes in your category, usually defined via
     16  polynomials. Your morphism class should derive from
     17  :class:`SchemeMorphism_polynomial`. These morphisms will usually be
     18  elements of the hom set
    1919  :class:`~sage.schemes.generic.homset.SchemeHomset_generic`.
    2020
    21 Optionally, you can also provide a special hom set for your
     21Optionally, you can also provide a special hom set class for your
    2222subcategory of schemes. If you want to do this, you should also
    2323provide a method
    2424
    25 * ``myscheme._homset_class(*args, **kwds)`` (optional) return the
    26   homset, which must be a derived class of
     25* ``myscheme._homset_class(*args, **kwds)`` returning a
     26  homset, which must be an element of a derived class of
    2727  `class:`~sage.schemes.generic.homset.SchemeHomset_generic`. If your
    2828  new homset class does not use ``myscheme._morphism_class`` then you
    2929  do not have to provide it.
     
    3232typically use a different notation, so they are implemented in a
    3333different derived class. For this, you should implement a method
    3434
    35 * ``myscheme._point_class(*args, **kwds)`` return a point, that is,
    36   morphism `Spec(K)\to X`. Your point class should derive from
     35* ``myscheme._point_class(*args, **kwds)`` returning a point, that is,
     36  a morphism `Spec(K)\to X`. Your point class should derive from
    3737  :class:`SchemeMorphism_point`.
    3838
    3939Optionally, you can also provide a special hom set for the points, for
    4040example the point hom set can provide a method to enumerate all
    4141points. If you want to do this, you should also provide a method
    4242
    43 * ``myscheme._point_homset_class(*args, **kwds)`` (optional) return
     43* ``myscheme._point_homset_class(*args, **kwds)`` returning
    4444  the :mod:`~sage.schemes.generic.homset` of points. The hom sets of
    4545  points are implemented in classes named ``SchemeHomset_points_...``.
    4646  If your new homset class does not use ``myscheme._point_class`` then
     
    6262# * _homset_class -> _point_homset_class
    6363
    6464#*****************************************************************************
    65 #  Copyright (C) 2006 David Kohel <kohel@maths.usyd.edu.au>
    66 #  Copyright (C) 2006 William Stein <wstein@gmail.com>
     65#       Copyright (C) 2011 Volker Braun <vbraun.name@gmail.com>
     66#       Copyright (C) 2006 David Kohel <kohel@maths.usyd.edu.au>
     67#       Copyright (C) 2006 William Stein <wstein@gmail.com>
     68#
    6769#  Distributed under the terms of the GNU General Public License (GPL)
     70#  as published by the Free Software Foundation; either version 2 of
     71#  the License, or (at your option) any later version.
    6872#                  http://www.gnu.org/licenses/
    6973#*****************************************************************************
    7074
     75
    7176from sage.rings.infinity import infinity
    7277from sage.structure.element   import AdditiveGroupElement, RingElement, Element, generic_power
    7378from sage.structure.sequence  import Sequence
     
    613618
    614619    def _repr_defn(self):
    615620        r"""
    616         Return a string representation of the type of ``self``.
     621        Return a string representation of the definition of ``self``.
    617622
    618623        OUTPUT:
    619624
     
    625630            sage: phi = R.hom([QQ(7)])
    626631            sage: X = Spec(QQ); Y = Spec(R)
    627632            sage: f = X.hom(phi)
    628             sage: f._repr_type()
    629             'Affine Scheme'
     633            sage: print f._repr_defn()
     634            Ring morphism:
     635              From: Univariate Polynomial Ring in x over Rational Field
     636              To:   Rational Field
     637              Defn: x |--> 7
    630638        """
    631639        return repr(self.ring_homomorphism())
    632640       
     
    708716        sage: f = H([exp(x),exp(y)])
    709717        Traceback (most recent call last):
    710718        ...
    711         TypeError: polys (=[e^x, e^y]) must be elements of Multivariate
    712         Polynomial Ring in x, y over Rational Field
     719        TypeError: polys (=[e^x, e^y]) must be elements of
     720        Multivariate Polynomial Ring in x, y over Rational Field
    713721    """
    714722    def __init__(self, parent, polys, check=True):
    715723        """
  • sage/schemes/generic/scheme.py

    diff --git a/sage/schemes/generic/scheme.py b/sage/schemes/generic/scheme.py
    a b  
    44AUTHORS:
    55
    66- William Stein, David Kohel, Kiran Kedlaya (2008): added zeta_series
     7
     8- Volker Braun (2011-08-11): documenting, improving, refactoring.
    79"""
    810
    9 #*******************************************************************************
    10 #  Copyright (C) 2008 Kiran Kedlaya <kedlaya@mit.edu>
    11 #  Copyright (C) 2005 David Kohel <kohel@maths.usyd.edu.au>
    12 #  Copyright (C) 2005 William Stein
     11
     12#*****************************************************************************
     13#       Copyright (C) 2011 Volker Braun <vbraun.name@gmail.com>
     14#       Copyright (C) 2008 Kiran Kedlaya <kedlaya@mit.edu>
     15#       Copyright (C) 2005 David Kohel <kohel@maths.usyd.edu.au>
     16#       Copyright (C) 2005 William Stein
    1317#
    1418#  Distributed under the terms of the GNU General Public License (GPL)
    15 #
    16 #  The full text of the GPL is available at:
    17 #
     19#  as published by the Free Software Foundation; either version 2 of
     20#  the License, or (at your option) any later version.
    1821#                  http://www.gnu.org/licenses/
    19 #*******************************************************************************
     22#*****************************************************************************
     23
    2024
    2125from sage.misc.all import cached_method
    2226from sage.structure.parent import Parent
  • sage/schemes/generic/toric_morphism.py

    diff --git a/sage/schemes/generic/toric_morphism.py b/sage/schemes/generic/toric_morphism.py
    a b  
    2222
    2323The toric morphisms are perhaps the most mysterious at the
    2424beginning. Let us quickly review their definition (See Definition
    25 3.3.3 of [CLS]_). Let `\Sigma_1` a fan in `N_{1,\RR}` and `\Sigma_2` a
     253.3.3 of [CLS]_). Let `\Sigma_1` be a fan in `N_{1,\RR}` and `\Sigma_2` be a
    2626fan in `N_{2,\RR}`. A morphism `\phi: X_{\Sigma_1} \to X_{\Sigma_2}`
    2727of the associated toric varieties is toric if `\phi` maps the maximal
    2828torus `T_{N_1} \subseteq X_{\Sigma_1}` into `T_{N_2} \subseteq
     
    5656            [0 : u^2 + v^2 : u*v]
    5757
    5858This is a well-defined morphism of algebraic varieties because
    59 homogeneously rescaled points of `\mathbb{P}^1` map to the same point
    60 in `\mathbb{P}^2` up to its homogeneous rescalings. It is not
     59homogeneously rescaled coordinates of a point of `\mathbb{P}^1` map to the same
     60point in `\mathbb{P}^2` up to its homogeneous rescalings. It is not
    6161equivariant with respect to the torus actions
    6262
    6363.. math::
    6464
    6565    \CC^\times \times \mathbb{P}^1,
    6666    (\mu,[u:v]) \mapsto [u:\mu v]
    67     ,\quad
    68     \CC^\times \times \mathbb{P}^2,
    69     (\alpha,\beta,[x:y:z]) \mapsto [x:\alpha y:\beta z]
     67    \quad\text{and}\quad
     68    \left(\CC^\times\right)^2 \times \mathbb{P}^2,
     69    ((\alpha,\beta),[x:y:z]) \mapsto [x:\alpha y:\beta z]
    7070    ,
    7171
    72 though. Hence it is not a toric morphism. Clearly, the problem is that
     72hence it is not a toric morphism. Clearly, the problem is that
    7373the map in homogeneous coordinates contains summands that transform
    7474differently under the torus action. However, this is not the only
    7575difficulty. For example, consider ::
     
    108108      Defn: Defined by sending the Rational polyhedral fan in 1-d lattice N
    109109            to Rational polyhedral fan in 2-d lattice N.
    110110
    111 The fan morphism map is equivalent to the polynomial map::
     111The fan morphism map is equivalent to the following polynomial map::
    112112
    113113    sage: _.as_polynomial_map()
    114114    Scheme morphism:
     
    118118            [u : v : v]
    119119
    120120Finally, here is an example of a fan morphism that cannot be written
    121 with homogeneous polynomials. Consider the blowup `O_{\mathbb{P}^1}(2)
     121using homogeneous polynomials. Consider the blowup `O_{\mathbb{P}^1}(2)
    122122\to \CC^2/\ZZ_2`. In terms of toric data, this blowup is::
    123123           
    124124    sage: A2_Z2 = toric_varieties.A2_Z2()
     
    320320        OUTPUT:
    321321
    322322        A :class:`SchemeMorphism_polynomial_toric_variety`. Raises a
    323         ``TypeError`` if the morphism cannot be written in terms of
    324         homogeneous polynomials.
     323        ``TypeError`` if the morphism cannot be written in such a way.
    325324
    326325        EXAMPLES::
    327326       
     
    331330            sage: patch.as_fan_morphism()
    332331            Traceback (most recent call last):
    333332            ...
    334             NotImplementedError
     333            NotImplementedError: expressing toric morphisms as fan morphisms is
     334            not implemented yet!
    335335        """
    336         raise NotImplementedError
     336        raise NotImplementedError("expressing toric morphisms as fan "
     337                                  "morphisms is not implemented yet!")
    337338
    338339       
    339340############################################################################
  • sage/schemes/generic/toric_variety.py

    diff --git a/sage/schemes/generic/toric_variety.py b/sage/schemes/generic/toric_variety.py
    a b  
    11501150            True
    11511151
    11521152        Note that by homogeneous, we mean well-defined with respect to
    1153         the homogeneous rescalings. So a polynomial that you would
     1153        the homogeneous rescalings of ``self``. So a polynomial that you would
    11541154        usually not call homogeneous can be homogeneous if there are
    11551155        no homogeneous rescalings, for example::
    11561156