21
21
# http://www.gnu.org/licenses/
22
22
#*****************************************************************************
23
23
24
-
25
24
from sage .structure .parent import Parent
26
25
from sage .misc .all import cached_method
27
26
from sage .rings .all import (IntegerRing ,
28
27
ZZ , GF , PowerSeriesRing ,
29
28
Rationals )
30
29
31
30
from sage .rings .commutative_ring import is_CommutativeRing
31
+ from sage .rings .ideal import is_Ideal
32
32
from sage .rings .morphism import is_RingHomomorphism
33
33
34
+ from sage .schemes .generic .point import SchemeTopologicalPoint_prime_ideal
35
+
34
36
def is_Scheme (x ):
35
37
"""
36
38
Test whether ``x`` is a scheme.
@@ -92,14 +94,16 @@ def __init__(self, X=None, category=None):
92
94
"""
93
95
Construct a scheme.
94
96
95
- TESTS::
97
+ TESTS:
98
+
99
+ The full test suite works since :trac:`7946`::
96
100
97
101
sage: R.<x, y> = QQ[]
98
102
sage: I = (x^2 - y^2)*R
99
103
sage: RmodI = R.quotient(I)
100
104
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
+
103
107
"""
104
108
from sage .schemes .generic .morphism import is_SchemeMorphism
105
109
@@ -190,7 +194,7 @@ def _morphism(self, *args, **kwds):
190
194
191
195
TESTS:
192
196
193
- This shows that issue at trac ticket 7389 is solved::
197
+ This shows that issue at : trac:` 7389` is solved::
194
198
195
199
sage: S = Spec(ZZ)
196
200
sage: f = S.identity_morphism()
@@ -992,7 +996,7 @@ def __call__(self, *args):
992
996
sage: P = S(ZZ.ideal(3)); P
993
997
Point on Spectrum of Integer Ring defined by the Principal ideal (3) of Integer Ring
994
998
sage: type(P)
995
- <class 'sage.schemes.generic.point.SchemeTopologicalPoint_prime_ideal '>
999
+ <class 'sage.schemes.generic.point.AffineScheme_with_category.element_class '>
996
1000
sage: S(ZZ.ideal(next_prime(1000000)))
997
1001
Point on Spectrum of Integer Ring defined by the Principal ideal (1000003) of Integer Ring
998
1002
@@ -1015,15 +1019,69 @@ def __call__(self, *args):
1015
1019
Set of morphisms
1016
1020
From: Spectrum of Integer Ring
1017
1021
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,)
1018
1048
"""
1019
1049
if len (args ) == 1 :
1020
- from sage .rings .ideal import is_Ideal
1021
1050
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
1025
1066
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 ))
1027
1085
1028
1086
def _an_element_ (self ):
1029
1087
r"""
0 commit comments