Changeset 8419:6054b29ac8d6


Ignore:
Timestamp:
11/11/07 13:49:40 (6 years ago)
Author:
David Roe <roed@…>
Branch:
default
Message:

Added sections of morphisms.

Location:
sage/categories
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sage/categories/category_types.py

    r6995 r8419  
    283283        return Sets, tuple([]) 
    284284 
     285############################################################# 
     286# Pointed Sets 
     287############################################################# 
     288 
     289class PointedSets(Category_uniq): 
     290    """ 
     291    The category of pointed sets. 
     292 
     293    EXAMPLES: 
     294        sage: PointedSets() 
     295        Category of pointed sets 
     296    """ 
     297    def __call__(self, X, pt): 
     298        import sage.sets.all 
     299        return sage.sets.all.Set(X, pt) 
     300 
     301    def __reduce__(self): 
     302        return PointedSets, tuple([]) 
     303 
     304############################################################# 
     305# Sets with Partial Maps 
     306############################################################# 
     307 
     308class SetsWithPartialMaps(Category_uniq): 
     309    """ 
     310    The category whose objects are sets and whose morphisms are 
     311    maps that are allowed to raise a ValueError on some inputs. 
     312 
     313    This category is equivalent to the category of pointed sets, 
     314    via the equivalence sending an object X to X union {error}, 
     315    a morphism f to the morphism of pointed sets that sends x 
     316    to f(x) if f does not raise an error on x, or to error if it 
     317    does. 
     318 
     319    EXAMPLES: 
     320        sage: SetsWithPartialMaps() 
     321        Category of Sets with  
     322    """ 
     323    def __call__(self, X, pt): 
     324        import sage.sets.all 
     325        return sage.sets.all.Set(X, pt) 
     326 
     327    def __reduce__(self): 
     328        return SetsWithPartialMaps, tuple([]) 
     329 
     330    def __repr__(self): 
     331        return "Category with objects Sets and morphisms partially defined maps" 
    285332 
    286333############################################################# 
     
    295342        sage: S = SymmetricGroup(3) 
    296343        sage: GSets(S) 
    297         Category of G-sets for SymmetricGroup(3) 
     344        Category of G-sets for Symmetric group of order 3! as a permutation group 
    298345    """ 
    299346    def __init__(self, G): 
  • sage/categories/morphism.pxd

    r6774 r8419  
    1616    cdef Element _call_c_impl(self, Element x)  
    1717 
     18cdef class Section(Morphism): 
     19    cdef Morphism _morphism 
     20 
    1821cdef class FormalCoercionMorphism(Morphism): 
    1922    cdef Element _call_c(self, x) 
  • sage/categories/morphism.pyx

    r7681 r8419  
    164164        return generic_power(self, n) 
    165165 
     166cdef class Section(Morphism): 
     167    def __init__(self, morphism): 
     168        from sage.categories.homset import Hom 
     169        from sage.categories.category_types import SetsWithPartialMaps 
     170        Morphism.__init__(self, Hom(morphism.codomain(), morphism.domain(), SetsWithPartialMaps())) 
     171        self._morphism = morphism 
     172 
     173    def _repr_type(self): 
     174        return "Section" 
     175 
    166176cdef class FormalCoercionMorphism(Morphism): 
    167177    def __init__(self, parent): 
Note: See TracChangeset for help on using the changeset viewer.