2121# http://www.gnu.org/licenses/
2222#*****************************************************************************
2323
24-
2524from sage .structure .parent import Parent
2625from sage .misc .all import cached_method
2726from sage .rings .all import (IntegerRing ,
2827 ZZ , GF , PowerSeriesRing ,
2928 Rationals )
3029
3130from sage .rings .commutative_ring import is_CommutativeRing
31+ from sage .rings .ideal import is_Ideal
3232from sage .rings .morphism import is_RingHomomorphism
3333
34+ from sage .schemes .generic .point import SchemeTopologicalPoint_prime_ideal
35+
3436def is_Scheme (x ):
3537 """
3638 Test whether ``x`` is a scheme.
@@ -92,14 +94,16 @@ def __init__(self, X=None, category=None):
9294 """
9395 Construct a scheme.
9496
95- TESTS::
97+ TESTS:
98+
99+ The full test suite works since :trac:`7946`::
96100
97101 sage: R.<x, y> = QQ[]
98102 sage: I = (x^2 - y^2)*R
99103 sage: RmodI = R.quotient(I)
100104 sage: X = Spec(RmodI)
101- sage: TestSuite(X).run(skip = ["_test_an_element", "_test_elements",
102- ... "_test_some_elements", "_test_category"]) # See #7946
105+ sage: TestSuite(X).run()
106+
103107 """
104108 from sage .schemes .generic .morphism import is_SchemeMorphism
105109
@@ -190,7 +194,7 @@ def _morphism(self, *args, **kwds):
190194
191195 TESTS:
192196
193- This shows that issue at trac ticket 7389 is solved::
197+ This shows that issue at : trac:` 7389` is solved::
194198
195199 sage: S = Spec(ZZ)
196200 sage: f = S.identity_morphism()
@@ -992,7 +996,7 @@ def __call__(self, *args):
992996 sage: P = S(ZZ.ideal(3)); P
993997 Point on Spectrum of Integer Ring defined by the Principal ideal (3) of Integer Ring
994998 sage: type(P)
995- <class 'sage.schemes.generic.point.SchemeTopologicalPoint_prime_ideal '>
999+ <class 'sage.schemes.generic.point.AffineScheme_with_category.element_class '>
9961000 sage: S(ZZ.ideal(next_prime(1000000)))
9971001 Point on Spectrum of Integer Ring defined by the Principal ideal (1000003) of Integer Ring
9981002
@@ -1015,15 +1019,69 @@ def __call__(self, *args):
10151019 Set of morphisms
10161020 From: Spectrum of Integer Ring
10171021 To: Spectrum of Integer Ring
1022+
1023+ For affine or projective varieties, passing the correct number
1024+ of elements of the base ring constructs the rational point
1025+ with these elements as coordinates::
1026+
1027+ sage: S = AffineSpace(ZZ, 1)
1028+ sage: S(0)
1029+ (0)
1030+
1031+ To prevent confusion with this usage, topological points must
1032+ be constructed by explicitly specifying a prime ideal, not
1033+ just generators::
1034+
1035+ sage: R = S.coordinate_ring()
1036+ sage: S(R.ideal(0))
1037+ Point on Affine Space of dimension 1 over Integer Ring defined by the Ideal (0) of Multivariate Polynomial Ring in x over Integer Ring
1038+
1039+ This explains why the following example raises an error rather
1040+ than constructing the topological point defined by the prime
1041+ ideal `(0)` as one might expect::
1042+
1043+ sage: S = Spec(ZZ)
1044+ sage: S(0)
1045+ Traceback (most recent call last):
1046+ ...
1047+ TypeError: cannot call Spectrum of Integer Ring with arguments (0,)
10181048 """
10191049 if len (args ) == 1 :
1020- from sage .rings .ideal import is_Ideal
10211050 x = args [0 ]
1022- if is_Ideal (x ) and x .ring () is self .coordinate_ring ():
1023- from sage .schemes .generic .point import SchemeTopologicalPoint_prime_ideal
1024- return SchemeTopologicalPoint_prime_ideal (self , x )
1051+ if ((isinstance (x , self .element_class ) and (x .parent () is self or x .parent () == self ))
1052+ or (is_Ideal (x ) and x .ring () is self .coordinate_ring ())):
1053+ # Construct a topological point from x.
1054+ return self ._element_constructor_ (x )
1055+ try :
1056+ # Construct a scheme homset or a scheme-valued point from
1057+ # args using the generic Scheme.__call__() method.
1058+ return super (AffineScheme , self ).__call__ (* args )
1059+ except NotImplementedError :
1060+ # This arises from self._morphism() not being implemented.
1061+ # We must convert it into a TypeError to keep the coercion
1062+ # system working.
1063+ raise TypeError ('cannot call %s with arguments %s' % (self , args ))
1064+
1065+ Element = SchemeTopologicalPoint_prime_ideal
10251066
1026- return super (AffineScheme , self ).__call__ (* args )
1067+ def _element_constructor_ (self , x ):
1068+ """
1069+ Construct a topological point from `x`.
1070+
1071+ TESTS::
1072+
1073+ sage: S = Spec(ZZ)
1074+ sage: S(ZZ.ideal(0))
1075+ Point on Spectrum of Integer Ring defined by the Principal ideal (0) of Integer Ring
1076+ """
1077+ if isinstance (x , self .element_class ):
1078+ if x .parent () is self :
1079+ return x
1080+ elif x .parent () == self :
1081+ return self .element_class (self , x .prime_ideal ())
1082+ elif is_Ideal (x ) and x .ring () is self .coordinate_ring ():
1083+ return self .element_class (self , x )
1084+ raise TypeError ('cannot convert %s to a topological point of %s' % (x , self ))
10271085
10281086 def _an_element_ (self ):
10291087 r"""
0 commit comments