Ticket #5891: categories-fixsagelib-nt.patch

File categories-fixsagelib-nt.patch, 36.4 KB (added by nthiery, 10 years ago)
  • sage/structure/element.pyx

    diff --git a/sage/structure/element.pyx b/sage/structure/element.pyx
    a b cdef class Element(sage_object.SageObjec 
    329329        return self._parent.base_ring()
    330330
    331331    def category(self):
    332         from sage.categories.category_types import Elements
     332        from sage.categories.all import Elements
    333333        return Elements(self._parent)
    334334
    335335    def parent(self, x=None):
  • sage/structure/wrapper_parent.pyx

    diff --git a/sage/structure/wrapper_parent.pyx b/sage/structure/wrapper_parent.pyx
    a b include "../ext/stdsage.pxi" 
    4747
    4848import copy
    4949import inspect
    50 from sage.categories.category_types import Objects
     50from sage.categories.all import Objects
    5151from sage.categories.homset import Hom
    5252from sage.rings.ring import Ring
    5353from sage.categories.morphism import CallMorphism
  • sage/combinat/species/series.py

    diff --git a/sage/combinat/species/series.py b/sage/combinat/species/series.py
    a b from sage.misc.misc import repr_lincomb 
    3636from sage.algebras.algebra import Algebra
    3737from sage.algebras.algebra_element import AlgebraElement
    3838import sage.structure.parent_base
    39 
     39from sage.categories.all import Rings
    4040
    4141class LazyPowerSeriesRing(Algebra):
    4242    def __init__(self, R, element_class = None, names=None):
    class LazyPowerSeriesRing(Algebra): 
    4949            Lazy Power Series Ring over Rational Field
    5050        """
    5151        #Make sure R is a ring with unit element
    52         if not isinstance(R, Ring):
     52        if not R in Rings():
    5353            raise TypeError, "Argument R must be a ring."
    5454        try:
    5555            z = R(Integer(1))
  • sage/modules/matrix_morphism.py

    diff --git a/sage/modules/matrix_morphism.py b/sage/modules/matrix_morphism.py
    a b AUTHOR: 
    5050"""
    5151
    5252
    53 import sage.categories.all
     53import sage.categories.morphism
    5454import sage.categories.homset
    5555import sage.matrix.all as matrix
    5656import sage.misc.misc as misc
    from sage.structure.all import Sequenc 
    6060def is_MatrixMorphism(x):
    6161    return isinstance(x, MatrixMorphism_abstract)
    6262
    63 class MatrixMorphism_abstract(sage.categories.all.Morphism):
     63class MatrixMorphism_abstract(sage.categories.morphism.Morphism):
    6464    def __init__(self, parent):
    6565        """
    6666        INPUT:
    class MatrixMorphism_abstract(sage.categ 
    8383        """
    8484        if not sage.categories.homset.is_Homset(parent):
    8585            raise TypeError, "parent must be a Hom space"
    86         sage.categories.all.Morphism.__init__(self, parent)
     86        sage.categories.morphism.Morphism.__init__(self, parent)
    8787
    8888    def __cmp__(self, other):
    8989        return cmp(self.matrix(), other.matrix())
  • sage/modules/module.pyx

    diff --git a/sage/modules/module.pyx b/sage/modules/module.pyx
    a b cdef class Module(sage.structure.parent_ 
    2323    """
    2424    Generic module class.
    2525    """
     26#    def __call__(self, x):
     27#        """
     28#        Coerce x into the ring.
     29#        """
     30#        raise NotImplementedError
     31    # Should be deprecated as soon as all modules declare their
     32    # category properly at initialization
    2633    def category(self):
    2734        """
    2835        Return the category to which this module belongs.
    2936        """
    30         import sage.categories.all
    31         return sage.categories.all.Modules(self.base_ring())
     37        category = sage.structure.category_object.CategoryObject.category(self)
     38        from sage.categories.all import Objects, Modules
     39        if category == Objects():
     40            return Modules(self.base_ring())
     41        else:
     42            return category
    3243
    3344    def endomorphism_ring(self):
    3445        """
  • sage/probability/random_variable.py

    diff --git a/sage/probability/random_variable.py b/sage/probability/random_variable.py
    a b functions. 
    1515#                  http://www.gnu.org/licenses/
    1616#*****************************************************************************
    1717
    18 import sage.categories.all
    19 
    2018from sage.structure.parent_base import ParentWithBase
    2119from sage.misc.functional import sqrt, log
    2220from sage.rings.all import RealField, RationalField, is_RealField, is_RationalField
  • sage/rings/homset.py

    diff --git a/sage/rings/homset.py b/sage/rings/homset.py
    a b Space of homomorphisms between two rings 
    1010#                  http://www.gnu.org/licenses/
    1111#*****************************************************************************
    1212
    13 from sage.categories.all import HomsetWithBase, Rings
     13from sage.categories.homset import HomsetWithBase
    1414from sage.structure.parent_base import ParentWithBase
    1515
    1616import morphism
    1717import quotient_ring
    1818
    19 RINGS = Rings()
    20 
    21 
    2219def is_RingHomset(H):
    2320    return isinstance(H, RingHomset_generic)
    2421
    25 def RingHomset(R, S):
     22def RingHomset(R, S, category = None):
    2623    if quotient_ring.is_QuotientRing(R):
    27         return RingHomset_quo_ring(R, S)
    28     return RingHomset_generic(R, S)
     24        return RingHomset_quo_ring(R, S, category = category)
     25    return RingHomset_generic(R, S, category = category)
    2926
    3027
    3128class RingHomset_generic(HomsetWithBase):
    32     def __init__(self, R, S):
    33         HomsetWithBase.__init__(self, R, S, RINGS)
     29    def __init__(self, R, S, category = None):
     30        if category is None:
     31            from sage.categories.rings import Rings
     32            category = Rings()
     33        HomsetWithBase.__init__(self, R, S, category)
    3434
    3535    def _repr_(self):
    3636        return "Set of Homomorphisms from %s to %s"%(self.domain(), self.codomain())
  • sage/rings/integer.pyx

    diff --git a/sage/rings/integer.pyx b/sage/rings/integer.pyx
    a b cdef class Integer(sage.structure.elemen 
    345345    # overhead can be significant. The difficulty is that then we can't
    346346    # guarantee that the initialization will be performed exactly once.
    347347
    348     def __cinit__(self, x=None, unsigned int base=0):
     348    def __cinit__(self, x=None, unsigned int base=0, parent=None):
    349349        mpz_init(self.value)
    350         self._parent = <SageObject>the_integer_ring
     350        if parent is None:
     351            self._parent = <SageObject>the_integer_ring
     352        else:
     353            self._parent = <SageObject>parent
    351354       
    352355    def __pyxdoc__init__(self):
    353356        """
    cdef class Integer(sage.structure.elemen 
    366369            8
    367370        """
    368371       
    369     def __init__(self, x=None, unsigned int base=0):
     372    def __init__(self, x=None, unsigned int base=0, parent=None):
    370373        """
    371374        EXAMPLES::
    372375       
  • sage/rings/morphism.pyx

    diff --git a/sage/rings/morphism.pyx b/sage/rings/morphism.pyx
    a b TESTS:: 
    384384include "../ext/cdefs.pxi"
    385385include "../ext/stdsage.pxi"
    386386
    387 from sage.categories.all import is_Homset, Sets
    388387import ideal
    389388
    390389import homset
    cdef class RingMap_lift(RingMap): 
    468467            sage: type(f)
    469468            <type 'sage.rings.morphism.RingMap_lift'>
    470469        """
     470        from sage.categories.sets_cat import Sets
    471471        H = R.Hom(S, Sets())
    472472        RingMap.__init__(self, H)
    473473        self.S = S  # for efficiency
  • sage/rings/number_field/class_group.py

    diff --git a/sage/rings/number_field/class_group.py b/sage/rings/number_field/class_group.py
    a b class ClassGroup(AbelianGroup_class): 
    3535        EXAMPLES::
    3636
    3737            sage: K.<a> = NumberField(x^2 + 23)
    38             sage: K.class_group()
     38            sage: G = K.class_group(); G
    3939            Class group of order 3 with structure C3 of Number Field in a with defining polynomial x^2 + 23
     40
     41            sage: G.category()
     42            Category of groups
     43            sage: G.check(verbose = True)  # todo: not implemented (test_an_element fails!)
    4044        """
    4145        self.__number_field = number_field
    4246        self.__gens = Sequence([FractionalIdealClass(x, self) for x in gens], immutable=True,
  • sage/rings/number_field/number_field_rel.py

    diff --git a/sage/rings/number_field/number_field_rel.py b/sage/rings/number_field/number_field_rel.py
    a b class NumberField_relative(NumberField_g 
    532532            sage: K.Hom(K)
    533533            Automorphism group of Number Field in a with defining polynomial x^3 - 2 over its base field
    534534            sage: type(K.Hom(K))
    535             <class 'sage.rings.number_field.morphism.RelativeNumberFieldHomset'>
     535            <class 'sage.rings.number_field.morphism.RelativeNumberFieldHomset_with_category'>
    536536        """
    537537        import morphism
    538538        return morphism.RelativeNumberFieldHomset(self, codomain)
  • sage/rings/residue_field.pyx

    diff --git a/sage/rings/residue_field.pyx b/sage/rings/residue_field.pyx
    a b include "../ext/stdsage.pxi" 
    102102from sage.rings.field import Field
    103103from sage.rings.integer import Integer
    104104from sage.categories.homset import Hom
    105 from sage.categories.category_types import Fields, Rings
     105from sage.categories.basic import Fields, Rings
    106106from sage.rings.all import ZZ, QQ, Integers
    107107from sage.rings.number_field.number_field_ideal import is_NumberFieldIdeal
    108108import weakref
  • sage/rings/ring.pyx

    diff --git a/sage/rings/ring.pyx b/sage/rings/ring.pyx
    a b cdef class Ring(ParentWithGens): 
    202202        Return the category to which this ring belongs.
    203203
    204204        EXAMPLES:
    205             sage: QQ['x,y'].category()
     205            sage: FreeAlgebra(QQ, 3, 'x').category() # todo: put in a real ring, not an algebra!
    206206            Category of rings
     207
    207208        """
    208         from sage.categories.all import Rings
     209        from sage.categories.rings import Rings
    209210        return Rings()
    210211
    211212    def ideal(self, *x, **kwds):
    cdef class Ring(ParentWithGens): 
    326327            return x
    327328        return self._zero_element
    328329
     330    zero = zero_element # transitional
     331
    329332    def one_element(self):
    330333        """
    331334        Return the one element of this ring (cached), if it exists.
    cdef class Ring(ParentWithGens): 
    348351            return x
    349352        return self._one_element
    350353
     354    one = one_element # Transitional
     355
    351356    def is_atomic_repr(self):
    352357        """
    353358        True if the elements have atomic string representations, in the sense
    cdef class CommutativeRing(Ring): 
    756761        """
    757762        import sage.modules.all
    758763        return sage.modules.all.FreeModule(self, n)
     764
     765    def category(self):
     766        """
     767        Return the category to which this ring belongs.
     768
     769        EXAMPLES:
     770            sage: QQ['x,y'].category()
     771            Category of commutative rings
     772        """
     773        from sage.categories.commutative_rings import CommutativeRings
     774        return CommutativeRings()
    759775   
    760776    def is_commutative(self):
    761777        """
    cdef class Field(PrincipalIdealDomain): 
    13261342            sage: F.category()
    13271343            Category of number fields
    13281344        """
    1329         from sage.categories.all import Fields
     1345        from sage.categories.fields import Fields
    13301346        return Fields()
    13311347       
    13321348    def fraction_field(self):
    def is_Ring(x): 
    21282144        sage: is_Ring(ZZ)
    21292145        True
    21302146    """
    2131     return isinstance(x, Ring)
     2147    from sage.categories.rings import Rings
     2148    return isinstance(x, Ring) or x in Rings()
    21322149
    21332150
    21342151from sage.structure.parent_gens import _certify_names
  • sage/schemes/elliptic_curves/ell_torsion.py

    diff --git a/sage/schemes/elliptic_curves/ell_torsion.py b/sage/schemes/elliptic_curves/ell_torsion.py
    a b class EllipticCurveTorsionSubgroup(group 
    111111        sage: T = EK.torsion_subgroup(); T
    112112        Torsion Subgroup isomorphic to Multiplicative Abelian Group isomorphic to C5 associated to the Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-10)*x + (-20) over Number Field in i with defining polynomial x^2 + 1
    113113        sage: type(T)
    114         <class 'sage.schemes.elliptic_curves.ell_torsion.EllipticCurveTorsionSubgroup'>
     114        <class 'sage.schemes.elliptic_curves.ell_torsion.EllipticCurveTorsionSubgroup_with_category'>
    115115
    116116
    117117    AUTHORS:
    class EllipticCurveTorsionSubgroup(group 
    149149            sage: T = EK.torsion_subgroup(); T
    150150            Torsion Subgroup isomorphic to Multiplicative Abelian Group isomorphic to C5 associated to the Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-10)*x + (-20) over Number Field in i with defining polynomial x^2 + 1
    151151            sage: type(T)
    152             <class 'sage.schemes.elliptic_curves.ell_torsion.EllipticCurveTorsionSubgroup'>
     152            <class 'sage.schemes.elliptic_curves.ell_torsion.EllipticCurveTorsionSubgroup_with_category'>
    153153        """
    154154        self.__E = E
    155155        self.__K = E.base_field()
  • sage/schemes/generic/homset.py

    diff --git a/sage/schemes/generic/homset.py b/sage/schemes/generic/homset.py
    a b def enum_affine_finite_field(X): 
    143143
    144144import sage.structure.parent_old as parent_old
    145145
    146 from sage.categories.all import HomsetWithBase, Schemes
    147 from sage.rings.all      import (
    148     is_FiniteField, is_RationalField, is_RingHomomorphism, ZZ)
     146from sage.categories.homset import HomsetWithBase
     147from sage.rings.integer_ring import ZZ
     148from sage.rings.ring import is_FiniteField
     149from sage.rings.rational_field import is_RationalField
     150from sage.rings.morphism import is_RingHomomorphism
    149151import spec
    150152
    151153import morphism
    152154
    153 SCH = Schemes()
    154 
    155155def is_SchemeHomset(H):
    156156    return isinstance(H, SchemeHomset_generic)
    157157
    158 def SchemeHomset(R, S, cat=None, check=True):
     158def SchemeHomset(R, S, category=None, check=True):
    159159    if spec.is_Spec(R) and spec.is_Spec(S):
    160         return SchemeHomset_spec(R, S, cat=cat, check=check)
     160        return SchemeHomset_spec(R, S, category=category, check=check)
    161161    else:
    162         return SchemeHomset_generic(R, S, cat=cat, check=check)
     162        return SchemeHomset_generic(R, S, category=category, check=check)
    163163
    164164class SchemeHomset_generic(parent_old.Parent, HomsetWithBase):
    165     def __init__(self, X, Y, cat=None, check=True, base=ZZ):
    166         HomsetWithBase.__init__(self, X, Y, cat=cat, check=check, base=base)
     165    def __init__(self, X, Y, category=None, check=True, base=ZZ):
     166        HomsetWithBase.__init__(self, X, Y, category=category, check=check, base=base)
    167167
    168168    def has_coerce_map_from_impl(self, S):
    169169        if self == S:   # an obvious case
    class SchemeHomset_projective_coordinate 
    320320            raise TypeError, "Unable to enumerate points over %s."%R
    321321
    322322class SchemeHomsetModule_abelian_variety_coordinates_field(SchemeHomset_projective_coordinates_field):
    323     def __init__(self, X, S, cat=None, check=True):
     323    def __init__(self, X, S, category=None, check=True):
    324324        r"""
    325325        EXAMPLES: The bug reported at trac #1785 is fixed::
    326326       
    class SchemeHomsetModule_abelian_variety 
    341341        if R != S:
    342342            X = X.base_extend(S)
    343343        Y = spec.Spec(S, R)
    344         HomsetWithBase.__init__(self, Y, X, cat=cat,
     344        HomsetWithBase.__init__(self, Y, X, category=category,
    345345                                check = check,
    346346                                base = sage.rings.integer_ring.ZZ)
    347347
  • sage/schemes/generic/scheme.py

    diff --git a/sage/schemes/generic/scheme.py b/sage/schemes/generic/scheme.py
    a b AUTHORS: 
    1919#*******************************************************************************
    2020
    2121from sage.structure.parent_base import ParentWithBase
    22 from sage.categories.all import Schemes
    2322from sage.rings.all import (IntegerRing, is_CommutativeRing, is_Field,
    2423                            ZZ, is_RingHomomorphism, GF, PowerSeriesRing,
    2524                            Rationals)
    2625
    27 SCH = Schemes()
    28 
    2926import homset
    3027
    3128import morphism
    class Scheme(ParentWithBase): 
    354351        try:
    355352            return self._base_morphism
    356353        except AttributeError:
     354            from sage.categories.schemes import Schemes
     355            SCH = Schemes()
    357356            if hasattr(self, '_base_scheme'):
    358                 self._base_morphism = self.Hom(self._base_scheme, cat=SCH).natural_map()
     357                self._base_morphism = self.Hom(self._base_scheme, category=SCH).natural_map()
    359358            elif hasattr(self, '_base_ring'):
    360                 self._base_morphism = self.Hom(spec.Spec(self._base_ring), cat=SCH).natural_map()
     359                self._base_morphism = self.Hom(spec.Spec(self._base_ring), category=SCH).natural_map()
    361360            else:
    362                 self._base_morphism = self.Hom(spec.SpecZ, cat=SCH).natural_map()
     361                self._base_morphism = self.Hom(spec.SpecZ, category=SCH).natural_map()
    363362            return self._base_morphism
    364363
    365364    structure_morphism = base_morphism
    class Scheme(ParentWithBase): 
    374373            sage: ProjectiveSpace(4, QQ).category()
    375374            Category of schemes over Spectrum of Rational Field
    376375        """
     376        from sage.categories.schemes import Schemes
    377377        return Schemes(self.base_scheme())
    378378
    379379    def coordinate_ring(self):
    class Scheme(ParentWithBase): 
    468468                raise TypeError, "unable to determine codomain"
    469469        return self.Hom(Y)(x)
    470470
    471     def _Hom_(self, Y, cat=None, check=True):
     471    def _Hom_(self, Y, category=None, check=True):
    472472        """
    473473        Return the set of scheme morphisms from self to Y.
    474474       
    class Scheme(ParentWithBase): 
    479479            sage: S._Hom_(P)
    480480            Set of points of Projective Space of dimension 3 over Integer Ring defined over Integer Ring
    481481        """
    482         return homset.SchemeHomset(self, Y, cat=cat, check=check)
     482        return homset.SchemeHomset(self, Y, category=category, check=check)
    483483
    484484    point_set = point_homset
    485485
  • sage/schemes/generic/spec.py

    diff --git a/sage/schemes/generic/spec.py b/sage/schemes/generic/spec.py
    a b Spec of a ring 
    88#                  http://www.gnu.org/licenses/
    99#*******************************************************************************
    1010
    11 from sage.rings.all import is_CommutativeRing, ZZ
     11from sage.rings.commutative_ring import is_CommutativeRing
     12from sage.rings.integer_ring import ZZ
    1213import scheme
    1314import point
    1415
  • sage/schemes/hyperelliptic_curves/kummer_surface.py

    diff --git a/sage/schemes/hyperelliptic_curves/kummer_surface.py b/sage/schemes/hyperelliptic_curves/kummer_surface.py
    a b from sage.schemes.generic.all import Pro 
    1212from sage.schemes.generic.algebraic_scheme \
    1313     import AlgebraicScheme_subscheme_projective
    1414from sage.categories.homset import Hom
    15 from sage.categories.category_types import Schemes
     15from sage.categories.all import Schemes
    1616
    1717# The generic genus 2 curve in Weierstrass form:
    1818#
  • sage/categories/action.pyx

    diff --git a/sage/categories/action.pyx b/sage/categories/action.pyx
    a b include "../ext/stdsage.pxi" 
    3939cdef class Action(Functor):
    4040   
    4141    def __init__(self, G, S, bint is_left = 1, op=None):
    42         from category_types import Groupoid
     42        from groupoid import Groupoid
    4343        Functor.__init__(self, Groupoid(G), S.category())
    4444        self.G = G
    4545        self.S = S
  • sage/categories/functor.pyx

    diff --git a/sage/categories/functor.pyx b/sage/categories/functor.pyx
    a b def ForgetfulFunctor(domain, codomain): 
    151151        sage: F
    152152        The forgetful functor from Rings to AbelianGroups
    153153    """
    154     from category_types import category_hierarchy
    155154    if domain == codomain:
    156155        return IdentityFunctor(domain, codomain)
    157156    if not domain.is_subcategory(codomain):
  • sage/categories/pushout.py

    diff --git a/sage/categories/pushout.py b/sage/categories/pushout.py
    a b  
    11from functor import Functor
    2 from category_types import *
     2from basic import *
    33
    44# TODO, think through the rankings, and override pushout where necessary.
    55
    class PolynomialFunctor(ConstructionFunc 
    107107    rank = 9
    108108
    109109    def __init__(self, var, multi_variate=False):
     110        from rings import Rings
    110111        Functor.__init__(self, Rings(), Rings())
    111112        self.var = var
    112113        self.multi_variate = multi_variate
  • sage/groups/abelian_gps/abelian_group.py

    diff --git a/sage/groups/abelian_gps/abelian_group.py b/sage/groups/abelian_gps/abelian_group.py
    a b from sage.rings.arith import factor,is_p 
    160160from abelian_group_element import AbelianGroupElement,is_AbelianGroupElement
    161161from sage.misc.misc import add, prod
    162162from sage.misc.mrange import mrange
     163#from sage.categories.commutative_groups import CommutativeGroups
    163164import sage.groups.group as group
    164165from sage.rings.integer_ring import IntegerRing
    165166ZZ = IntegerRing()
    class AbelianGroup_class(group.AbelianGr 
    399400        [1]
    400401        sage: AbelianGroup(3, [2, 1, 2], names=list('abc')).list()
    401402        [1, b, a, a*b]
     403
     404        sage: F.category()
     405        Category of groups
     406
    402407    """
    403408    def __init__(self, n, invfac, names="f"):
    404409        #invfac.sort()
    class AbelianGroup_class(group.AbelianGr 
    422427        # *now* define ngens
    423428        self.__ngens = len(self.__invariants)
    424429        self._assign_names(names[:n])
     430        from sage.categories.groups import Groups
     431        group.Group.__init__(self, category = Groups()) # should be CommutativeGroups()
    425432
    426433    def __call__(self, x):
    427434        """
  • sage/groups/group.pyx

    diff --git a/sage/groups/group.pyx b/sage/groups/group.pyx
    a b cdef class Group(sage.structure.parent_g 
    3030    """
    3131    Generic group class
    3232    """
    33     def __init__(self):
     33    def __init__(self, category = None):
     34        """
     35
     36        TESTS::
     37            sage: from sage.groups.group import Group
     38            sage: G = Group()
     39            sage: G.category()
     40            Category of groups
     41            sage: G = Group(category = Groups()) # todo: do the same test with some subcategory of Groups when there will exist one
     42            sage: G.category()
     43            Category of groups
     44            sage: G = Group(category = AbelianGroups())
     45            Traceback (most recent call last):
     46            ...
     47            AssertionError: Category of abelian groups is not a subcategory of Category of groups
     48           
     49        """
     50        from sage.categories.basic import Groups
     51        if category is None:
     52            category = Groups()
     53        else:
     54            assert category.is_subcategory(Groups()), "%s is not a subcategory of %s"%(category, Groups())
     55           
    3456        sage.structure.parent_gens.ParentWithGens.__init__(self,
    35                 sage.rings.integer_ring.ZZ)
     57                sage.rings.integer_ring.ZZ, category = category)
    3658   
    3759    def __call__(self, x):
    3860        """
    cdef class Group(sage.structure.parent_g 
    5072            return False
    5173        return True
    5274
    53     def category(self):
    54         """
    55         The category of all groups
    56         """
    57         import sage.categories.all
    58         return sage.categories.all.Groups()
     75#    def category(self):
     76#        """
     77#        The category of all groups
     78#        """
     79#        import sage.categories.all
     80#        return sage.categories.all.Groups()
    5981
    6082    def is_atomic_repr(self):
    6183        """
  • sage/groups/matrix_gps/homset.py

    diff --git a/sage/groups/matrix_gps/homset.py b/sage/groups/matrix_gps/homset.py
    a b AUTHORS: 
    1818
    1919from sage.groups.group_homset import GroupHomset_generic
    2020from sage.categories.homset import HomsetWithBase
    21 from sage.categories.category_types import Groups
     21from sage.categories.all import Groups
    2222GROUPS = Groups()
    2323
    2424import matrix_group_morphism
  • sage/groups/perm_gps/permgroup.py

    diff --git a/sage/groups/perm_gps/permgroup.py b/sage/groups/perm_gps/permgroup.py
    a b class PermutationGroup_generic(group.Fin 
    319319            Permutation Group with generators [(2,3,4), (1,2,3)]
    320320            sage: A4.center()
    321321            Permutation Group with generators [()]
     322            sage: A4.category()
     323            Category of groups
    322324            sage: loads(A4.dumps()) == A4
    323325            True
    324326        """
     327        super(PermutationGroup_generic, self).__init__()
    325328        if (gens is None and gap_group is None):
    326329            raise ValueError, "you must specify gens or gap_group"
    327330
  • sage/groups/perm_gps/permgroup_named.py

    diff --git a/sage/groups/perm_gps/permgroup_named.py b/sage/groups/perm_gps/permgroup_named.py
    a b from sage.interfaces.all import gap, is_ 
    7676import sage.structure.coerce as coerce
    7777from sage.rings.finite_field import FiniteField as GF
    7878from sage.rings.arith import factor
     79from sage.groups.group import FiniteGroup
    7980from sage.groups.abelian_gps.abelian_group import AbelianGroup
    8081from sage.misc.functional import is_even, log
    8182from sage.groups.perm_gps.permgroup import PermutationGroup, PermutationGroup_generic
    class SymmetricGroup(PermutationGroup_sy 
    181182            Symmetric group of order 4! as a permutation group
    182183            sage: G.set()
    183184            [1, 2, 3, 4]
     185
     186            sage: G.category()
     187            Category of groups
    184188        """
    185189        self._set = self._get_set(n)
    186190        self._deg = max(self._set)
    class SymmetricGroup(PermutationGroup_sy 
    194198            if n > 2:
    195199                gens.append( tuple(self._set[:2]) )
    196200
    197         #Note that we don't call the superclass initializer in order to
     201        #Note that we skip the call to the superclass initializer in order to
    198202        #avoid infinite recursion since SymmetricGroup is called by
    199203        #PermutationGroupElement
     204        FiniteGroup.__init__(self)
     205
    200206        gens = [PermutationGroupElement(g, self, check=False) for g in gens]
    201207        self._gap_string = '%s(%s)'%(self._gap_name, n)
    202208        self._gens = gens
    class AlternatingGroup(PermutationGroup_ 
    250256            Alternating group of order 4!/2 as a permutation group
    251257            sage: G.set()
    252258            [1, 2, 4, 5]
     259            sage: G.category()
     260            Category of groups
    253261        """
    254262        self._set = self._get_set(n)
    255263        self._deg = max(self._set)
    class CyclicPermutationGroup(Permutation 
    289297            8
    290298            sage: G
    291299            Cyclic group of order 8 as a permutation group
     300            sage: G.category()
     301            Category of groups
    292302            sage: loads(G.dumps()) == G
    293303            True
    294304            sage: C = CyclicPermutationGroup(10)
    class CyclicPermutationGroup(Permutation 
    297307            sage: C = CyclicPermutationGroup(10)
    298308            sage: C.as_AbelianGroup()
    299309            Multiplicative Abelian Group isomorphic to C2 x C5
    300 
    301310        """
    302311        n = Integer(n)
    303312        if n < 1:
    class KleinFourGroup(PermutationGroup_ge 
    367376            [(), (3,4), (1,2), (1,2)(3,4)]       
    368377
    369378        TESTS:
     379            sage: G.category()
     380            Category of groups
    370381            sage: G == loads(dumps(G))
    371382            True
    372383     
    class DihedralGroup(PermutationGroup_gen 
    429440            ValueError: n must be positive
    430441
    431442        TESTS:
     443            sage: G.category()
     444            Category of groups
    432445            sage: G == loads(dumps(G))
    433446            True
    434447        """       
    class MathieuGroup(PermutationGroup_gene 
    479492            Mathieu group of degree 12 and order 95040 as a permutation group
    480493
    481494        TESTS:
     495            sage: G.category()
     496            Category of groups
    482497            sage: G == loads(dumps(G))
    483498            True
    484499        """       
    class TransitiveGroup(PermutationGroup_g 
    517532            sage: G.gens()                             # requires optional database_gap
    518533            [(1,2,3,4,5), (1,4)(2,3)]
    519534           
     535            sage: G.category()
     536            Category of groups
    520537            sage: loads(G.dumps()) == G                # requires optional database_gap
    521538            True
    522539        """
    class PGL(PermutationGroup_plg): 
    588605            Permutation Group with generators [(3,10,9,8,4,7,6,5), (1,2,4)(5,6,8)(7,9,10)]
    589606            sage: G.base_ring()
    590607            Finite Field in b of size 3^2           
     608
     609            sage: G.category()
     610            Category of groups
    591611        """
    592612        from sage.groups.perm_gps.permgroup import PermutationGroup, PermutationGroup_generic
    593613        id = 'Group([()])' if n == 1 else 'PGL(%s,%s)'%(n,q)
    class PSL(PermutationGroup_plg): 
    639659            sage: G.base_ring()
    640660            Finite Field in a of size 2^3
    641661           
     662            sage: G.category()
     663            Category of groups
    642664        """
    643665        if n == 1:
    644666            id = 'Group([()])'
  • sage/matrix/matrix_space.py

    diff --git a/sage/matrix/matrix_space.py b/sage/matrix/matrix_space.py
    a b import sage.modules.free_module_element 
    8585import sage.modules.free_module
    8686from sage.structure.sequence import Sequence
    8787
     88from sage.categories.rings import Rings
     89
    8890def is_MatrixSpace(x):
    8991    """
    9092    Returns True if self is an instance of MatrixSpace returns false if
    def MatrixSpace(base_ring, nrows, ncols= 
    183185        sage: loads(M.dumps()) == M
    184186        True
    185187    """
    186     if not sage.rings.ring.is_Ring(base_ring):
     188    if not base_ring in Rings():
    187189        raise TypeError, "base_ring (=%s) must be a ring"%base_ring
    188190   
    189191    if ncols is None: ncols = nrows
    class MatrixSpace_generic(parent_gens.Pa 
    208210   
    209211        sage: MatrixSpace(ZZ,10,5)
    210212        Full MatrixSpace of 10 by 5 dense matrices over Integer Ring
     213        sage: MatrixSpace(ZZ,10,5).category()
     214        Category of modules over Integer Ring
     215
    211216        sage: MatrixSpace(ZZ,10,2^31)
    212217        Traceback (most recent call last):                                   # 32-bit
    213218        ...                                                                  # 32-bit
    214219        ValueError: number of rows and columns must be less than 2^31 (on a 32-bit computer -- use a 64-bit computer for matrices with up to 2^63-1 rows and columns)           # 32-bit
    215220        Full MatrixSpace of 10 by 2147483648 dense matrices over Integer Ring   # 64-bit
    216221    """
     222
    217223    def __init__(self,  base_ring,             
    218224                        nrows,
    219225                        ncols=None,
    220226                        sparse=False):
    221         parent_gens.ParentWithGens.__init__(self, base_ring)
    222         if not isinstance(base_ring, ring.Ring):
     227
     228        from sage.categories.all import Modules
     229        parent_gens.ParentWithGens.__init__(self, base_ring) # category = Modules(base_ring)
     230        # Temporary until the inheritance glitches are fixed
     231        sage.structure.category_object.CategoryObject.__init_category__(self, Modules(base_ring))
     232
     233        if not base_ring in Rings():
    223234            raise TypeError, "base_ring must be a ring"
    224235        if ncols == None: ncols = nrows
    225236        nrows = int(nrows)
    class MatrixSpace_generic(parent_gens.Pa 
    552563        return "\\mathrm{Mat}_{%s\\times %s}(%s)"%(self.nrows(), self.ncols(),
    553564                                                      latex.latex(self.base_ring()))
    554565
     566    # This should eventually be inherited from the EnumeratedSets() category
     567    def list(self): return self._list_from_iterator_cached()
     568
    555569    def __iter__(self):
    556570        r"""
    557571        Returns a generator object which iterates through the elements of
  • sage/modular/abvar/homspace.py

    diff --git a/sage/modular/abvar/homspace.py b/sage/modular/abvar/homspace.py
    a b class Homspace(HomsetWithBase): 
    216216            sage: Hom(J0(11), J0(11))
    217217            Endomorphism ring of Abelian variety J0(11) of dimension 1
    218218            sage: type(H)
    219             <class 'sage.modular.abvar.homspace.Homspace'>
     219            <class 'sage.modular.abvar.homspace.Homspace_with_category'>
    220220            sage: H.homset_category()
    221221            Category of modular abelian varieties over Rational Field
    222222        """
    class EndomorphismSubring(Homspace, Ring 
    698698            sage: sage.modular.abvar.homspace.EndomorphismSubring(J0(25))
    699699            Endomorphism ring of Abelian variety J0(25) of dimension 0
    700700            sage: type(J0(11).endomorphism_ring())
    701             <class 'sage.modular.abvar.homspace.EndomorphismSubring'>
     701            <class 'sage.modular.abvar.homspace.EndomorphismSubring_with_category'>
    702702        """
    703703        self._J = A.ambient_variety()
    704704        self._A = A
  • sage/modular/hecke/degenmap.py

    diff --git a/sage/modular/hecke/degenmap.py b/sage/modular/hecke/degenmap.py
    a b class DegeneracyMap(morphism.HeckeModule 
    6060    """
    6161    def __init__(self, matrix, domain, codomain, t):
    6262        self.__t = t
    63         H = homspace.HeckeModuleHomspace(domain, codomain)
     63        H = domain.Hom(codomain)
    6464        if t == 1:
    6565            pow = ""
    6666        else:
  • sage/modular/hecke/hecke_operator.py

    diff --git a/sage/modular/hecke/hecke_operator.py b/sage/modular/hecke/hecke_operator.py
    a b import math 
    2222import operator
    2323
    2424import sage.algebras.algebra_element
    25 import sage.categories.all as cat
     25from sage.categories.homset import End
    2626import sage.misc.latex as latex
    2727import sage.misc.misc as misc
    2828import sage.modules.module
    class HeckeAlgebraElement(sage.algebras. 
    7474        except AttributeError:
    7575            T = self.matrix()
    7676            M = self.domain()
    77             H = cat.End(M)
     77            H = End(M)
    7878            if isinstance(self, HeckeOperator):
    7979                name = "T_%s"%self.index()
    8080            else:
  • sage/modular/hecke/homspace.py

    diff --git a/sage/modular/hecke/homspace.py b/sage/modular/hecke/homspace.py
    a b def is_HeckeModuleHomspace(x): 
    2525    return isinstance(x, HeckeModuleHomspace)
    2626
    2727class HeckeModuleHomspace(sage.categories.homset.HomsetWithBase):
    28     def __init__(self, X, Y):
     28    def __init__(self, X, Y, category = None):
    2929        if not module.is_HeckeModule(X) or not module.is_HeckeModule(Y):
    3030            raise TypeError, "X and Y must be Hecke modules"
    3131        if X.base_ring() != Y.base_ring():
    3232            raise TypeError, "X and Y must have the same base ring"
    33         sage.categories.homset.HomsetWithBase.__init__(self, X, Y, X.category())
     33        if category is None:
     34            category = X.category()
     35        sage.categories.homset.HomsetWithBase.__init__(self, X, Y, category)
    3436
    3537    def __call__(self, A, name=''):
    3638        try:
  • sage/modular/hecke/module.py

    diff --git a/sage/modular/hecke/module.py b/sage/modular/hecke/module.py
    a b class HeckeModule_free_module(HeckeModul 
    11311131            i = (A.decomposition()).index(self)
    11321132            n = sum([A[j].rank() for j in range(i)])
    11331133            C = B.matrix_from_columns(range(n,n+self.rank()))
    1134             H = homspace.HeckeModuleHomspace(A, self)
     1134            H = A.Hom(self)
    11351135            pi = H(C, "Projection"%self)
    11361136            self.__projection = pi
    11371137            return self.__projection
  • sage/modular/hecke/morphism.py

    diff --git a/sage/modular/hecke/morphism.py b/sage/modular/hecke/morphism.py
    a b AUTHORS: 
    2525
    2626
    2727import sage.misc.misc as misc
    28 import sage.categories.all as cat
    2928from sage.modules.matrix_morphism import MatrixMorphism
     29from sage.categories.morphism import Morphism
    3030
    3131# We also define other types of Hecke-module morphisms that aren't
    3232# specified by a matrix.  E.g., Hecke operators, or maybe morphisms on
    def is_HeckeModuleMorphism(x): 
    3939def is_HeckeModuleMorphism_matrix(x):
    4040    return isinstance(x, HeckeModuleMorphism_matrix)
    4141
    42 class HeckeModuleMorphism(cat.Morphism):
     42class HeckeModuleMorphism(Morphism):
    4343    pass
    4444
    4545class HeckeModuleMorphism_matrix(MatrixMorphism, HeckeModuleMorphism):
  • sage/modular/modsym/ambient.py

    diff --git a/sage/modular/modsym/ambient.py b/sage/modular/modsym/ambient.py
    a b class ModularSymbolsAmbient(space.Modula 
    715715        """
    716716       
    717717        MS = matrix_space.MatrixSpace(self.base_ring(), self.dimension(), M.dimension())
    718         hom = hecke.HeckeModuleHomspace(self, M)
     718        hom = self.Hom(M)
    719719        if self.dimension() == 0 or M.dimension() == 0:
    720720            A = MS(0)
    721721            phi = hom(A, "Heilbronn operator(%s,%s)"%(H,t))