def __init__(self, parent, phi, check=True): """ The Python constuctor. See :class:`SchemeMorphism_structure_map` for details. TESTS:: sage: from sage.schemes.generic.morphism import SchemeMorphism_spec sage: SchemeMorphism_spec(Spec(QQ).Hom(Spec(ZZ)), ZZ.hom(QQ)) Affine Scheme morphism: From: Spectrum of Rational Field To: Spectrum of Integer Ring Defn: Ring Coercion morphism: From: Integer Ring To: Rational Field """ SchemeMorphism.__init__(self, parent) if check: if not is_RingHomomorphism(phi): raise TypeError("phi (=%s) must be a ring homomorphism" % phi) if phi.domain() != parent.codomain().coordinate_ring(): raise TypeError("phi (=%s) must have domain %s" % (phi, parent.codomain().coordinate_ring())) if phi.codomain() != parent.domain().coordinate_ring(): raise TypeError("phi (=%s) must have codomain %s" % (phi, parent.domain().coordinate_ring())) self.__ring_homomorphism = phi
def __init__(self, parent, codomain=None): """ The Python constructor. EXAMPLES:: sage: X = Spec(ZZ) sage: Hom = X.Hom(X) sage: from sage.schemes.generic.morphism import SchemeMorphism sage: f = SchemeMorphism(Hom) sage: type(f) <class 'sage.schemes.generic.morphism.SchemeMorphism'> """ if codomain is not None: parent = Hom(parent, codomain) if not isinstance(parent, Homset): raise TypeError("parent (=%s) must be a Homspace"%parent) Element.__init__(self, parent) self.domain = ConstantFunction(parent.domain()) self._codomain = parent.codomain() self.codomain = ConstantFunction(self._codomain)