Changeset 5498:dd7f96fc2561
- Timestamp:
- 07/24/07 11:21:37 (6 years ago)
- Branch:
- default
- Children:
- 5499:66c89ee30e12, 5858:90c27feeca40
- Location:
- sage
- Files:
-
- 3 edited
-
modules/free_module_element.pyx (modified) (1 diff)
-
schemes/generic/morphism.py (modified) (4 diffs)
-
structure/coerce.pxi (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
sage/modules/free_module_element.pyx
r5489 r5498 489 489 490 490 cdef ModuleElement _rmul_nonscalar_c_impl(left, right): 491 raise TypeError491 raise TypeError 492 492 493 493 def degree(self): -
sage/schemes/generic/morphism.py
r4853 r5498 14 14 #***************************************************************************** 15 15 16 from sage.structure.element import AdditiveGroupElement, RingElement 16 from sage.structure.element import AdditiveGroupElement, RingElement, Element 17 17 from sage.structure.sequence import Sequence 18 18 19 19 from sage.categories.morphism import Morphism 20 from sage.categories.homset import Homset 20 21 21 22 from sage.rings.all import is_RingHomomorphism, is_CommutativeRing, Integer … … 31 32 return isinstance(f, (SchemeMorphism, EllipticCurvePoint_field)); 32 33 33 class SchemeMorphism(Morphism): 34 35 class PyMorphism(Element): 36 # Double inheritance from both Morphism and AdditiveGroupElement seems to mess up the ModuleElement pyrex vtab, which is really bad! 37 def __init__(self, parent): 38 if not isinstance(parent, Homset): 39 raise TypeError, "parent (=%s) must be a Homspace"%parent 40 Element.__init__(self, parent) 41 self._domain = parent.domain() 42 self._codomain = parent.codomain() 43 44 def _repr_type(self): 45 return "Generic" 46 47 def _repr_defn(self): 48 return "" 49 50 def _repr_(self): 51 if self.is_endomorphism(): 52 s = "%s endomorphism of %s"%(self._repr_type(), self.domain()) 53 else: 54 s = "%s morphism:"%self._repr_type() 55 s += "\n From: %s"%self.domain() 56 s += "\n To: %s"%self.codomain() 57 d = self._repr_defn() 58 if d != '': 59 s += "\n Defn: %s"%('\n '.join(self._repr_defn().split('\n'))) 60 return s 61 62 def domain(self): 63 return self._domain 64 65 def codomain(self): 66 return self.parent().codomain() 67 68 def category(self): 69 return self.parent().category() 70 71 def is_endomorphism(self): 72 return self.parent().is_endomorphism_set() 73 74 def _composition_(self, right, homset): 75 return FormalCompositeMorphism(homset, right, self) 76 77 def __pow__(self, n, dummy): 78 if not self.is_endomorphism(): 79 raise TypeError, "self must be an endomorphism." 80 # todo -- what about the case n=0 -- need to specify the identity map somehow. 81 import sage.rings.arith as arith 82 return arith.generic_power(self, n) 83 84 85 86 class SchemeMorphism(PyMorphism): 34 87 """ 35 88 A scheme morphism 36 89 """ 37 90 def __init__(self, parent): 38 Morphism.__init__(self, parent)91 PyMorphism.__init__(self, parent) 39 92 40 93 def _repr_type(self): … … 149 202 """ 150 203 def __init__(self, parent, phi, check=True): 151 Morphism.__init__(self, parent)204 SchemeMorphism.__init__(self, parent) 152 205 if check: 153 206 if not is_RingHomomorphism(phi): … … 159 212 raise TypeError, "phi (=%s) must have codomain %s"%(phi, 160 213 parent.domain().coordinate_ring()) 161 self.__ring_homomorphism = phi214 self.__ring_homomorphism = phi 162 215 163 216 def __call__(self, P): -
sage/structure/coerce.pxi
r5465 r5497 38 38 if PY_TYPE_CHECK(x,Element): 39 39 return (<Element>x)._parent 40 try: 41 # TODO: should the _parent attribute be moved up the tree? 40 elif hasattr(x, 'parent'): 42 41 return x.parent() 43 e xcept AttributeError:42 else: 44 43 return <object>PY_TYPE(x) 45 44
Note: See TracChangeset
for help on using the changeset viewer.
