-
diff --git a/sage/structure/element.pyx b/sage/structure/element.pyx
a
|
b
|
cdef class Element(sage_object.SageObjec |
329 | 329 | return self._parent.base_ring() |
330 | 330 | |
331 | 331 | def category(self): |
332 | | from sage.categories.category_types import Elements |
| 332 | from sage.categories.all import Elements |
333 | 333 | return Elements(self._parent) |
334 | 334 | |
335 | 335 | def parent(self, x=None): |
-
diff --git a/sage/structure/wrapper_parent.pyx b/sage/structure/wrapper_parent.pyx
a
|
b
|
include "../ext/stdsage.pxi" |
47 | 47 | |
48 | 48 | import copy |
49 | 49 | import inspect |
50 | | from sage.categories.category_types import Objects |
| 50 | from sage.categories.all import Objects |
51 | 51 | from sage.categories.homset import Hom |
52 | 52 | from sage.rings.ring import Ring |
53 | 53 | from sage.categories.morphism import CallMorphism |
-
diff --git a/sage/combinat/species/series.py b/sage/combinat/species/series.py
a
|
b
|
from sage.misc.misc import repr_lincomb |
36 | 36 | from sage.algebras.algebra import Algebra |
37 | 37 | from sage.algebras.algebra_element import AlgebraElement |
38 | 38 | import sage.structure.parent_base |
39 | | |
| 39 | from sage.categories.all import Rings |
40 | 40 | |
41 | 41 | class LazyPowerSeriesRing(Algebra): |
42 | 42 | def __init__(self, R, element_class = None, names=None): |
… |
… |
class LazyPowerSeriesRing(Algebra): |
49 | 49 | Lazy Power Series Ring over Rational Field |
50 | 50 | """ |
51 | 51 | #Make sure R is a ring with unit element |
52 | | if not isinstance(R, Ring): |
| 52 | if not R in Rings(): |
53 | 53 | raise TypeError, "Argument R must be a ring." |
54 | 54 | try: |
55 | 55 | z = R(Integer(1)) |
-
diff --git a/sage/modules/matrix_morphism.py b/sage/modules/matrix_morphism.py
a
|
b
|
AUTHOR: |
50 | 50 | """ |
51 | 51 | |
52 | 52 | |
53 | | import sage.categories.all |
| 53 | import sage.categories.morphism |
54 | 54 | import sage.categories.homset |
55 | 55 | import sage.matrix.all as matrix |
56 | 56 | import sage.misc.misc as misc |
… |
… |
from sage.structure.all import Sequenc |
60 | 60 | def is_MatrixMorphism(x): |
61 | 61 | return isinstance(x, MatrixMorphism_abstract) |
62 | 62 | |
63 | | class MatrixMorphism_abstract(sage.categories.all.Morphism): |
| 63 | class MatrixMorphism_abstract(sage.categories.morphism.Morphism): |
64 | 64 | def __init__(self, parent): |
65 | 65 | """ |
66 | 66 | INPUT: |
… |
… |
class MatrixMorphism_abstract(sage.categ |
83 | 83 | """ |
84 | 84 | if not sage.categories.homset.is_Homset(parent): |
85 | 85 | raise TypeError, "parent must be a Hom space" |
86 | | sage.categories.all.Morphism.__init__(self, parent) |
| 86 | sage.categories.morphism.Morphism.__init__(self, parent) |
87 | 87 | |
88 | 88 | def __cmp__(self, other): |
89 | 89 | return cmp(self.matrix(), other.matrix()) |
-
diff --git a/sage/modules/module.pyx b/sage/modules/module.pyx
a
|
b
|
cdef class Module(sage.structure.parent_ |
23 | 23 | """ |
24 | 24 | Generic module class. |
25 | 25 | """ |
| 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 |
26 | 33 | def category(self): |
27 | 34 | """ |
28 | 35 | Return the category to which this module belongs. |
29 | 36 | """ |
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 |
32 | 43 | |
33 | 44 | def endomorphism_ring(self): |
34 | 45 | """ |
-
diff --git a/sage/probability/random_variable.py b/sage/probability/random_variable.py
a
|
b
|
functions. |
15 | 15 | # http://www.gnu.org/licenses/ |
16 | 16 | #***************************************************************************** |
17 | 17 | |
18 | | import sage.categories.all |
19 | | |
20 | 18 | from sage.structure.parent_base import ParentWithBase |
21 | 19 | from sage.misc.functional import sqrt, log |
22 | 20 | from sage.rings.all import RealField, RationalField, is_RealField, is_RationalField |
-
diff --git a/sage/rings/homset.py b/sage/rings/homset.py
a
|
b
|
Space of homomorphisms between two rings |
10 | 10 | # http://www.gnu.org/licenses/ |
11 | 11 | #***************************************************************************** |
12 | 12 | |
13 | | from sage.categories.all import HomsetWithBase, Rings |
| 13 | from sage.categories.homset import HomsetWithBase |
14 | 14 | from sage.structure.parent_base import ParentWithBase |
15 | 15 | |
16 | 16 | import morphism |
17 | 17 | import quotient_ring |
18 | 18 | |
19 | | RINGS = Rings() |
20 | | |
21 | | |
22 | 19 | def is_RingHomset(H): |
23 | 20 | return isinstance(H, RingHomset_generic) |
24 | 21 | |
25 | | def RingHomset(R, S): |
| 22 | def RingHomset(R, S, category = None): |
26 | 23 | 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) |
29 | 26 | |
30 | 27 | |
31 | 28 | class 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) |
34 | 34 | |
35 | 35 | def _repr_(self): |
36 | 36 | return "Set of Homomorphisms from %s to %s"%(self.domain(), self.codomain()) |
-
diff --git a/sage/rings/integer.pyx b/sage/rings/integer.pyx
a
|
b
|
cdef class Integer(sage.structure.elemen |
345 | 345 | # overhead can be significant. The difficulty is that then we can't |
346 | 346 | # guarantee that the initialization will be performed exactly once. |
347 | 347 | |
348 | | def __cinit__(self, x=None, unsigned int base=0): |
| 348 | def __cinit__(self, x=None, unsigned int base=0, parent=None): |
349 | 349 | 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 |
351 | 354 | |
352 | 355 | def __pyxdoc__init__(self): |
353 | 356 | """ |
… |
… |
cdef class Integer(sage.structure.elemen |
366 | 369 | 8 |
367 | 370 | """ |
368 | 371 | |
369 | | def __init__(self, x=None, unsigned int base=0): |
| 372 | def __init__(self, x=None, unsigned int base=0, parent=None): |
370 | 373 | """ |
371 | 374 | EXAMPLES:: |
372 | 375 | |
-
diff --git a/sage/rings/morphism.pyx b/sage/rings/morphism.pyx
a
|
b
|
TESTS:: |
384 | 384 | include "../ext/cdefs.pxi" |
385 | 385 | include "../ext/stdsage.pxi" |
386 | 386 | |
387 | | from sage.categories.all import is_Homset, Sets |
388 | 387 | import ideal |
389 | 388 | |
390 | 389 | import homset |
… |
… |
cdef class RingMap_lift(RingMap): |
468 | 467 | sage: type(f) |
469 | 468 | <type 'sage.rings.morphism.RingMap_lift'> |
470 | 469 | """ |
| 470 | from sage.categories.sets_cat import Sets |
471 | 471 | H = R.Hom(S, Sets()) |
472 | 472 | RingMap.__init__(self, H) |
473 | 473 | self.S = S # for efficiency |
-
diff --git a/sage/rings/number_field/class_group.py b/sage/rings/number_field/class_group.py
a
|
b
|
class ClassGroup(AbelianGroup_class): |
35 | 35 | EXAMPLES:: |
36 | 36 | |
37 | 37 | sage: K.<a> = NumberField(x^2 + 23) |
38 | | sage: K.class_group() |
| 38 | sage: G = K.class_group(); G |
39 | 39 | 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!) |
40 | 44 | """ |
41 | 45 | self.__number_field = number_field |
42 | 46 | self.__gens = Sequence([FractionalIdealClass(x, self) for x in gens], immutable=True, |
-
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 |
532 | 532 | sage: K.Hom(K) |
533 | 533 | Automorphism group of Number Field in a with defining polynomial x^3 - 2 over its base field |
534 | 534 | sage: type(K.Hom(K)) |
535 | | <class 'sage.rings.number_field.morphism.RelativeNumberFieldHomset'> |
| 535 | <class 'sage.rings.number_field.morphism.RelativeNumberFieldHomset_with_category'> |
536 | 536 | """ |
537 | 537 | import morphism |
538 | 538 | return morphism.RelativeNumberFieldHomset(self, codomain) |
-
diff --git a/sage/rings/residue_field.pyx b/sage/rings/residue_field.pyx
a
|
b
|
include "../ext/stdsage.pxi" |
102 | 102 | from sage.rings.field import Field |
103 | 103 | from sage.rings.integer import Integer |
104 | 104 | from sage.categories.homset import Hom |
105 | | from sage.categories.category_types import Fields, Rings |
| 105 | from sage.categories.basic import Fields, Rings |
106 | 106 | from sage.rings.all import ZZ, QQ, Integers |
107 | 107 | from sage.rings.number_field.number_field_ideal import is_NumberFieldIdeal |
108 | 108 | import weakref |
-
diff --git a/sage/rings/ring.pyx b/sage/rings/ring.pyx
a
|
b
|
cdef class Ring(ParentWithGens): |
202 | 202 | Return the category to which this ring belongs. |
203 | 203 | |
204 | 204 | EXAMPLES: |
205 | | sage: QQ['x,y'].category() |
| 205 | sage: FreeAlgebra(QQ, 3, 'x').category() # todo: put in a real ring, not an algebra! |
206 | 206 | Category of rings |
| 207 | |
207 | 208 | """ |
208 | | from sage.categories.all import Rings |
| 209 | from sage.categories.rings import Rings |
209 | 210 | return Rings() |
210 | 211 | |
211 | 212 | def ideal(self, *x, **kwds): |
… |
… |
cdef class Ring(ParentWithGens): |
326 | 327 | return x |
327 | 328 | return self._zero_element |
328 | 329 | |
| 330 | zero = zero_element # transitional |
| 331 | |
329 | 332 | def one_element(self): |
330 | 333 | """ |
331 | 334 | Return the one element of this ring (cached), if it exists. |
… |
… |
cdef class Ring(ParentWithGens): |
348 | 351 | return x |
349 | 352 | return self._one_element |
350 | 353 | |
| 354 | one = one_element # Transitional |
| 355 | |
351 | 356 | def is_atomic_repr(self): |
352 | 357 | """ |
353 | 358 | True if the elements have atomic string representations, in the sense |
… |
… |
cdef class CommutativeRing(Ring): |
756 | 761 | """ |
757 | 762 | import sage.modules.all |
758 | 763 | 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() |
759 | 775 | |
760 | 776 | def is_commutative(self): |
761 | 777 | """ |
… |
… |
cdef class Field(PrincipalIdealDomain): |
1326 | 1342 | sage: F.category() |
1327 | 1343 | Category of number fields |
1328 | 1344 | """ |
1329 | | from sage.categories.all import Fields |
| 1345 | from sage.categories.fields import Fields |
1330 | 1346 | return Fields() |
1331 | 1347 | |
1332 | 1348 | def fraction_field(self): |
… |
… |
def is_Ring(x): |
2128 | 2144 | sage: is_Ring(ZZ) |
2129 | 2145 | True |
2130 | 2146 | """ |
2131 | | return isinstance(x, Ring) |
| 2147 | from sage.categories.rings import Rings |
| 2148 | return isinstance(x, Ring) or x in Rings() |
2132 | 2149 | |
2133 | 2150 | |
2134 | 2151 | from sage.structure.parent_gens import _certify_names |
-
diff --git a/sage/schemes/elliptic_curves/ell_torsion.py b/sage/schemes/elliptic_curves/ell_torsion.py
a
|
b
|
class EllipticCurveTorsionSubgroup(group |
111 | 111 | sage: T = EK.torsion_subgroup(); T |
112 | 112 | 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 |
113 | 113 | sage: type(T) |
114 | | <class 'sage.schemes.elliptic_curves.ell_torsion.EllipticCurveTorsionSubgroup'> |
| 114 | <class 'sage.schemes.elliptic_curves.ell_torsion.EllipticCurveTorsionSubgroup_with_category'> |
115 | 115 | |
116 | 116 | |
117 | 117 | AUTHORS: |
… |
… |
class EllipticCurveTorsionSubgroup(group |
149 | 149 | sage: T = EK.torsion_subgroup(); T |
150 | 150 | 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 |
151 | 151 | sage: type(T) |
152 | | <class 'sage.schemes.elliptic_curves.ell_torsion.EllipticCurveTorsionSubgroup'> |
| 152 | <class 'sage.schemes.elliptic_curves.ell_torsion.EllipticCurveTorsionSubgroup_with_category'> |
153 | 153 | """ |
154 | 154 | self.__E = E |
155 | 155 | self.__K = E.base_field() |
-
diff --git a/sage/schemes/generic/homset.py b/sage/schemes/generic/homset.py
a
|
b
|
def enum_affine_finite_field(X): |
143 | 143 | |
144 | 144 | import sage.structure.parent_old as parent_old |
145 | 145 | |
146 | | from sage.categories.all import HomsetWithBase, Schemes |
147 | | from sage.rings.all import ( |
148 | | is_FiniteField, is_RationalField, is_RingHomomorphism, ZZ) |
| 146 | from sage.categories.homset import HomsetWithBase |
| 147 | from sage.rings.integer_ring import ZZ |
| 148 | from sage.rings.ring import is_FiniteField |
| 149 | from sage.rings.rational_field import is_RationalField |
| 150 | from sage.rings.morphism import is_RingHomomorphism |
149 | 151 | import spec |
150 | 152 | |
151 | 153 | import morphism |
152 | 154 | |
153 | | SCH = Schemes() |
154 | | |
155 | 155 | def is_SchemeHomset(H): |
156 | 156 | return isinstance(H, SchemeHomset_generic) |
157 | 157 | |
158 | | def SchemeHomset(R, S, cat=None, check=True): |
| 158 | def SchemeHomset(R, S, category=None, check=True): |
159 | 159 | 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) |
161 | 161 | else: |
162 | | return SchemeHomset_generic(R, S, cat=cat, check=check) |
| 162 | return SchemeHomset_generic(R, S, category=category, check=check) |
163 | 163 | |
164 | 164 | class 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) |
167 | 167 | |
168 | 168 | def has_coerce_map_from_impl(self, S): |
169 | 169 | if self == S: # an obvious case |
… |
… |
class SchemeHomset_projective_coordinate |
320 | 320 | raise TypeError, "Unable to enumerate points over %s."%R |
321 | 321 | |
322 | 322 | class 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): |
324 | 324 | r""" |
325 | 325 | EXAMPLES: The bug reported at trac #1785 is fixed:: |
326 | 326 | |
… |
… |
class SchemeHomsetModule_abelian_variety |
341 | 341 | if R != S: |
342 | 342 | X = X.base_extend(S) |
343 | 343 | Y = spec.Spec(S, R) |
344 | | HomsetWithBase.__init__(self, Y, X, cat=cat, |
| 344 | HomsetWithBase.__init__(self, Y, X, category=category, |
345 | 345 | check = check, |
346 | 346 | base = sage.rings.integer_ring.ZZ) |
347 | 347 | |
-
diff --git a/sage/schemes/generic/scheme.py b/sage/schemes/generic/scheme.py
a
|
b
|
AUTHORS: |
19 | 19 | #******************************************************************************* |
20 | 20 | |
21 | 21 | from sage.structure.parent_base import ParentWithBase |
22 | | from sage.categories.all import Schemes |
23 | 22 | from sage.rings.all import (IntegerRing, is_CommutativeRing, is_Field, |
24 | 23 | ZZ, is_RingHomomorphism, GF, PowerSeriesRing, |
25 | 24 | Rationals) |
26 | 25 | |
27 | | SCH = Schemes() |
28 | | |
29 | 26 | import homset |
30 | 27 | |
31 | 28 | import morphism |
… |
… |
class Scheme(ParentWithBase): |
354 | 351 | try: |
355 | 352 | return self._base_morphism |
356 | 353 | except AttributeError: |
| 354 | from sage.categories.schemes import Schemes |
| 355 | SCH = Schemes() |
357 | 356 | 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() |
359 | 358 | 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() |
361 | 360 | 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() |
363 | 362 | return self._base_morphism |
364 | 363 | |
365 | 364 | structure_morphism = base_morphism |
… |
… |
class Scheme(ParentWithBase): |
374 | 373 | sage: ProjectiveSpace(4, QQ).category() |
375 | 374 | Category of schemes over Spectrum of Rational Field |
376 | 375 | """ |
| 376 | from sage.categories.schemes import Schemes |
377 | 377 | return Schemes(self.base_scheme()) |
378 | 378 | |
379 | 379 | def coordinate_ring(self): |
… |
… |
class Scheme(ParentWithBase): |
468 | 468 | raise TypeError, "unable to determine codomain" |
469 | 469 | return self.Hom(Y)(x) |
470 | 470 | |
471 | | def _Hom_(self, Y, cat=None, check=True): |
| 471 | def _Hom_(self, Y, category=None, check=True): |
472 | 472 | """ |
473 | 473 | Return the set of scheme morphisms from self to Y. |
474 | 474 | |
… |
… |
class Scheme(ParentWithBase): |
479 | 479 | sage: S._Hom_(P) |
480 | 480 | Set of points of Projective Space of dimension 3 over Integer Ring defined over Integer Ring |
481 | 481 | """ |
482 | | return homset.SchemeHomset(self, Y, cat=cat, check=check) |
| 482 | return homset.SchemeHomset(self, Y, category=category, check=check) |
483 | 483 | |
484 | 484 | point_set = point_homset |
485 | 485 | |
-
diff --git a/sage/schemes/generic/spec.py b/sage/schemes/generic/spec.py
a
|
b
|
Spec of a ring |
8 | 8 | # http://www.gnu.org/licenses/ |
9 | 9 | #******************************************************************************* |
10 | 10 | |
11 | | from sage.rings.all import is_CommutativeRing, ZZ |
| 11 | from sage.rings.commutative_ring import is_CommutativeRing |
| 12 | from sage.rings.integer_ring import ZZ |
12 | 13 | import scheme |
13 | 14 | import point |
14 | 15 | |
-
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 |
12 | 12 | from sage.schemes.generic.algebraic_scheme \ |
13 | 13 | import AlgebraicScheme_subscheme_projective |
14 | 14 | from sage.categories.homset import Hom |
15 | | from sage.categories.category_types import Schemes |
| 15 | from sage.categories.all import Schemes |
16 | 16 | |
17 | 17 | # The generic genus 2 curve in Weierstrass form: |
18 | 18 | # |
-
diff --git a/sage/categories/action.pyx b/sage/categories/action.pyx
a
|
b
|
include "../ext/stdsage.pxi" |
39 | 39 | cdef class Action(Functor): |
40 | 40 | |
41 | 41 | def __init__(self, G, S, bint is_left = 1, op=None): |
42 | | from category_types import Groupoid |
| 42 | from groupoid import Groupoid |
43 | 43 | Functor.__init__(self, Groupoid(G), S.category()) |
44 | 44 | self.G = G |
45 | 45 | self.S = S |
-
diff --git a/sage/categories/functor.pyx b/sage/categories/functor.pyx
a
|
b
|
def ForgetfulFunctor(domain, codomain): |
151 | 151 | sage: F |
152 | 152 | The forgetful functor from Rings to AbelianGroups |
153 | 153 | """ |
154 | | from category_types import category_hierarchy |
155 | 154 | if domain == codomain: |
156 | 155 | return IdentityFunctor(domain, codomain) |
157 | 156 | if not domain.is_subcategory(codomain): |
-
diff --git a/sage/categories/pushout.py b/sage/categories/pushout.py
a
|
b
|
|
1 | 1 | from functor import Functor |
2 | | from category_types import * |
| 2 | from basic import * |
3 | 3 | |
4 | 4 | # TODO, think through the rankings, and override pushout where necessary. |
5 | 5 | |
… |
… |
class PolynomialFunctor(ConstructionFunc |
107 | 107 | rank = 9 |
108 | 108 | |
109 | 109 | def __init__(self, var, multi_variate=False): |
| 110 | from rings import Rings |
110 | 111 | Functor.__init__(self, Rings(), Rings()) |
111 | 112 | self.var = var |
112 | 113 | self.multi_variate = multi_variate |
-
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 |
160 | 160 | from abelian_group_element import AbelianGroupElement,is_AbelianGroupElement |
161 | 161 | from sage.misc.misc import add, prod |
162 | 162 | from sage.misc.mrange import mrange |
| 163 | #from sage.categories.commutative_groups import CommutativeGroups |
163 | 164 | import sage.groups.group as group |
164 | 165 | from sage.rings.integer_ring import IntegerRing |
165 | 166 | ZZ = IntegerRing() |
… |
… |
class AbelianGroup_class(group.AbelianGr |
399 | 400 | [1] |
400 | 401 | sage: AbelianGroup(3, [2, 1, 2], names=list('abc')).list() |
401 | 402 | [1, b, a, a*b] |
| 403 | |
| 404 | sage: F.category() |
| 405 | Category of groups |
| 406 | |
402 | 407 | """ |
403 | 408 | def __init__(self, n, invfac, names="f"): |
404 | 409 | #invfac.sort() |
… |
… |
class AbelianGroup_class(group.AbelianGr |
422 | 427 | # *now* define ngens |
423 | 428 | self.__ngens = len(self.__invariants) |
424 | 429 | self._assign_names(names[:n]) |
| 430 | from sage.categories.groups import Groups |
| 431 | group.Group.__init__(self, category = Groups()) # should be CommutativeGroups() |
425 | 432 | |
426 | 433 | def __call__(self, x): |
427 | 434 | """ |
-
diff --git a/sage/groups/group.pyx b/sage/groups/group.pyx
a
|
b
|
cdef class Group(sage.structure.parent_g |
30 | 30 | """ |
31 | 31 | Generic group class |
32 | 32 | """ |
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 | |
34 | 56 | sage.structure.parent_gens.ParentWithGens.__init__(self, |
35 | | sage.rings.integer_ring.ZZ) |
| 57 | sage.rings.integer_ring.ZZ, category = category) |
36 | 58 | |
37 | 59 | def __call__(self, x): |
38 | 60 | """ |
… |
… |
cdef class Group(sage.structure.parent_g |
50 | 72 | return False |
51 | 73 | return True |
52 | 74 | |
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() |
59 | 81 | |
60 | 82 | def is_atomic_repr(self): |
61 | 83 | """ |
-
diff --git a/sage/groups/matrix_gps/homset.py b/sage/groups/matrix_gps/homset.py
a
|
b
|
AUTHORS: |
18 | 18 | |
19 | 19 | from sage.groups.group_homset import GroupHomset_generic |
20 | 20 | from sage.categories.homset import HomsetWithBase |
21 | | from sage.categories.category_types import Groups |
| 21 | from sage.categories.all import Groups |
22 | 22 | GROUPS = Groups() |
23 | 23 | |
24 | 24 | import matrix_group_morphism |
-
diff --git a/sage/groups/perm_gps/permgroup.py b/sage/groups/perm_gps/permgroup.py
a
|
b
|
class PermutationGroup_generic(group.Fin |
319 | 319 | Permutation Group with generators [(2,3,4), (1,2,3)] |
320 | 320 | sage: A4.center() |
321 | 321 | Permutation Group with generators [()] |
| 322 | sage: A4.category() |
| 323 | Category of groups |
322 | 324 | sage: loads(A4.dumps()) == A4 |
323 | 325 | True |
324 | 326 | """ |
| 327 | super(PermutationGroup_generic, self).__init__() |
325 | 328 | if (gens is None and gap_group is None): |
326 | 329 | raise ValueError, "you must specify gens or gap_group" |
327 | 330 | |
-
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_ |
76 | 76 | import sage.structure.coerce as coerce |
77 | 77 | from sage.rings.finite_field import FiniteField as GF |
78 | 78 | from sage.rings.arith import factor |
| 79 | from sage.groups.group import FiniteGroup |
79 | 80 | from sage.groups.abelian_gps.abelian_group import AbelianGroup |
80 | 81 | from sage.misc.functional import is_even, log |
81 | 82 | from sage.groups.perm_gps.permgroup import PermutationGroup, PermutationGroup_generic |
… |
… |
class SymmetricGroup(PermutationGroup_sy |
181 | 182 | Symmetric group of order 4! as a permutation group |
182 | 183 | sage: G.set() |
183 | 184 | [1, 2, 3, 4] |
| 185 | |
| 186 | sage: G.category() |
| 187 | Category of groups |
184 | 188 | """ |
185 | 189 | self._set = self._get_set(n) |
186 | 190 | self._deg = max(self._set) |
… |
… |
class SymmetricGroup(PermutationGroup_sy |
194 | 198 | if n > 2: |
195 | 199 | gens.append( tuple(self._set[:2]) ) |
196 | 200 | |
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 |
198 | 202 | #avoid infinite recursion since SymmetricGroup is called by |
199 | 203 | #PermutationGroupElement |
| 204 | FiniteGroup.__init__(self) |
| 205 | |
200 | 206 | gens = [PermutationGroupElement(g, self, check=False) for g in gens] |
201 | 207 | self._gap_string = '%s(%s)'%(self._gap_name, n) |
202 | 208 | self._gens = gens |
… |
… |
class AlternatingGroup(PermutationGroup_ |
250 | 256 | Alternating group of order 4!/2 as a permutation group |
251 | 257 | sage: G.set() |
252 | 258 | [1, 2, 4, 5] |
| 259 | sage: G.category() |
| 260 | Category of groups |
253 | 261 | """ |
254 | 262 | self._set = self._get_set(n) |
255 | 263 | self._deg = max(self._set) |
… |
… |
class CyclicPermutationGroup(Permutation |
289 | 297 | 8 |
290 | 298 | sage: G |
291 | 299 | Cyclic group of order 8 as a permutation group |
| 300 | sage: G.category() |
| 301 | Category of groups |
292 | 302 | sage: loads(G.dumps()) == G |
293 | 303 | True |
294 | 304 | sage: C = CyclicPermutationGroup(10) |
… |
… |
class CyclicPermutationGroup(Permutation |
297 | 307 | sage: C = CyclicPermutationGroup(10) |
298 | 308 | sage: C.as_AbelianGroup() |
299 | 309 | Multiplicative Abelian Group isomorphic to C2 x C5 |
300 | | |
301 | 310 | """ |
302 | 311 | n = Integer(n) |
303 | 312 | if n < 1: |
… |
… |
class KleinFourGroup(PermutationGroup_ge |
367 | 376 | [(), (3,4), (1,2), (1,2)(3,4)] |
368 | 377 | |
369 | 378 | TESTS: |
| 379 | sage: G.category() |
| 380 | Category of groups |
370 | 381 | sage: G == loads(dumps(G)) |
371 | 382 | True |
372 | 383 | |
… |
… |
class DihedralGroup(PermutationGroup_gen |
429 | 440 | ValueError: n must be positive |
430 | 441 | |
431 | 442 | TESTS: |
| 443 | sage: G.category() |
| 444 | Category of groups |
432 | 445 | sage: G == loads(dumps(G)) |
433 | 446 | True |
434 | 447 | """ |
… |
… |
class MathieuGroup(PermutationGroup_gene |
479 | 492 | Mathieu group of degree 12 and order 95040 as a permutation group |
480 | 493 | |
481 | 494 | TESTS: |
| 495 | sage: G.category() |
| 496 | Category of groups |
482 | 497 | sage: G == loads(dumps(G)) |
483 | 498 | True |
484 | 499 | """ |
… |
… |
class TransitiveGroup(PermutationGroup_g |
517 | 532 | sage: G.gens() # requires optional database_gap |
518 | 533 | [(1,2,3,4,5), (1,4)(2,3)] |
519 | 534 | |
| 535 | sage: G.category() |
| 536 | Category of groups |
520 | 537 | sage: loads(G.dumps()) == G # requires optional database_gap |
521 | 538 | True |
522 | 539 | """ |
… |
… |
class PGL(PermutationGroup_plg): |
588 | 605 | Permutation Group with generators [(3,10,9,8,4,7,6,5), (1,2,4)(5,6,8)(7,9,10)] |
589 | 606 | sage: G.base_ring() |
590 | 607 | Finite Field in b of size 3^2 |
| 608 | |
| 609 | sage: G.category() |
| 610 | Category of groups |
591 | 611 | """ |
592 | 612 | from sage.groups.perm_gps.permgroup import PermutationGroup, PermutationGroup_generic |
593 | 613 | id = 'Group([()])' if n == 1 else 'PGL(%s,%s)'%(n,q) |
… |
… |
class PSL(PermutationGroup_plg): |
639 | 659 | sage: G.base_ring() |
640 | 660 | Finite Field in a of size 2^3 |
641 | 661 | |
| 662 | sage: G.category() |
| 663 | Category of groups |
642 | 664 | """ |
643 | 665 | if n == 1: |
644 | 666 | id = 'Group([()])' |
-
diff --git a/sage/matrix/matrix_space.py b/sage/matrix/matrix_space.py
a
|
b
|
import sage.modules.free_module_element |
85 | 85 | import sage.modules.free_module |
86 | 86 | from sage.structure.sequence import Sequence |
87 | 87 | |
| 88 | from sage.categories.rings import Rings |
| 89 | |
88 | 90 | def is_MatrixSpace(x): |
89 | 91 | """ |
90 | 92 | Returns True if self is an instance of MatrixSpace returns false if |
… |
… |
def MatrixSpace(base_ring, nrows, ncols= |
183 | 185 | sage: loads(M.dumps()) == M |
184 | 186 | True |
185 | 187 | """ |
186 | | if not sage.rings.ring.is_Ring(base_ring): |
| 188 | if not base_ring in Rings(): |
187 | 189 | raise TypeError, "base_ring (=%s) must be a ring"%base_ring |
188 | 190 | |
189 | 191 | if ncols is None: ncols = nrows |
… |
… |
class MatrixSpace_generic(parent_gens.Pa |
208 | 210 | |
209 | 211 | sage: MatrixSpace(ZZ,10,5) |
210 | 212 | 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 | |
211 | 216 | sage: MatrixSpace(ZZ,10,2^31) |
212 | 217 | Traceback (most recent call last): # 32-bit |
213 | 218 | ... # 32-bit |
214 | 219 | 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 |
215 | 220 | Full MatrixSpace of 10 by 2147483648 dense matrices over Integer Ring # 64-bit |
216 | 221 | """ |
| 222 | |
217 | 223 | def __init__(self, base_ring, |
218 | 224 | nrows, |
219 | 225 | ncols=None, |
220 | 226 | 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(): |
223 | 234 | raise TypeError, "base_ring must be a ring" |
224 | 235 | if ncols == None: ncols = nrows |
225 | 236 | nrows = int(nrows) |
… |
… |
class MatrixSpace_generic(parent_gens.Pa |
552 | 563 | return "\\mathrm{Mat}_{%s\\times %s}(%s)"%(self.nrows(), self.ncols(), |
553 | 564 | latex.latex(self.base_ring())) |
554 | 565 | |
| 566 | # This should eventually be inherited from the EnumeratedSets() category |
| 567 | def list(self): return self._list_from_iterator_cached() |
| 568 | |
555 | 569 | def __iter__(self): |
556 | 570 | r""" |
557 | 571 | Returns a generator object which iterates through the elements of |
-
diff --git a/sage/modular/abvar/homspace.py b/sage/modular/abvar/homspace.py
a
|
b
|
class Homspace(HomsetWithBase): |
216 | 216 | sage: Hom(J0(11), J0(11)) |
217 | 217 | Endomorphism ring of Abelian variety J0(11) of dimension 1 |
218 | 218 | sage: type(H) |
219 | | <class 'sage.modular.abvar.homspace.Homspace'> |
| 219 | <class 'sage.modular.abvar.homspace.Homspace_with_category'> |
220 | 220 | sage: H.homset_category() |
221 | 221 | Category of modular abelian varieties over Rational Field |
222 | 222 | """ |
… |
… |
class EndomorphismSubring(Homspace, Ring |
698 | 698 | sage: sage.modular.abvar.homspace.EndomorphismSubring(J0(25)) |
699 | 699 | Endomorphism ring of Abelian variety J0(25) of dimension 0 |
700 | 700 | sage: type(J0(11).endomorphism_ring()) |
701 | | <class 'sage.modular.abvar.homspace.EndomorphismSubring'> |
| 701 | <class 'sage.modular.abvar.homspace.EndomorphismSubring_with_category'> |
702 | 702 | """ |
703 | 703 | self._J = A.ambient_variety() |
704 | 704 | self._A = A |
-
diff --git a/sage/modular/hecke/degenmap.py b/sage/modular/hecke/degenmap.py
a
|
b
|
class DegeneracyMap(morphism.HeckeModule |
60 | 60 | """ |
61 | 61 | def __init__(self, matrix, domain, codomain, t): |
62 | 62 | self.__t = t |
63 | | H = homspace.HeckeModuleHomspace(domain, codomain) |
| 63 | H = domain.Hom(codomain) |
64 | 64 | if t == 1: |
65 | 65 | pow = "" |
66 | 66 | else: |
-
diff --git a/sage/modular/hecke/hecke_operator.py b/sage/modular/hecke/hecke_operator.py
a
|
b
|
import math |
22 | 22 | import operator |
23 | 23 | |
24 | 24 | import sage.algebras.algebra_element |
25 | | import sage.categories.all as cat |
| 25 | from sage.categories.homset import End |
26 | 26 | import sage.misc.latex as latex |
27 | 27 | import sage.misc.misc as misc |
28 | 28 | import sage.modules.module |
… |
… |
class HeckeAlgebraElement(sage.algebras. |
74 | 74 | except AttributeError: |
75 | 75 | T = self.matrix() |
76 | 76 | M = self.domain() |
77 | | H = cat.End(M) |
| 77 | H = End(M) |
78 | 78 | if isinstance(self, HeckeOperator): |
79 | 79 | name = "T_%s"%self.index() |
80 | 80 | else: |
-
diff --git a/sage/modular/hecke/homspace.py b/sage/modular/hecke/homspace.py
a
|
b
|
def is_HeckeModuleHomspace(x): |
25 | 25 | return isinstance(x, HeckeModuleHomspace) |
26 | 26 | |
27 | 27 | class HeckeModuleHomspace(sage.categories.homset.HomsetWithBase): |
28 | | def __init__(self, X, Y): |
| 28 | def __init__(self, X, Y, category = None): |
29 | 29 | if not module.is_HeckeModule(X) or not module.is_HeckeModule(Y): |
30 | 30 | raise TypeError, "X and Y must be Hecke modules" |
31 | 31 | if X.base_ring() != Y.base_ring(): |
32 | 32 | 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) |
34 | 36 | |
35 | 37 | def __call__(self, A, name=''): |
36 | 38 | try: |
-
diff --git a/sage/modular/hecke/module.py b/sage/modular/hecke/module.py
a
|
b
|
class HeckeModule_free_module(HeckeModul |
1131 | 1131 | i = (A.decomposition()).index(self) |
1132 | 1132 | n = sum([A[j].rank() for j in range(i)]) |
1133 | 1133 | C = B.matrix_from_columns(range(n,n+self.rank())) |
1134 | | H = homspace.HeckeModuleHomspace(A, self) |
| 1134 | H = A.Hom(self) |
1135 | 1135 | pi = H(C, "Projection"%self) |
1136 | 1136 | self.__projection = pi |
1137 | 1137 | return self.__projection |
-
diff --git a/sage/modular/hecke/morphism.py b/sage/modular/hecke/morphism.py
a
|
b
|
AUTHORS: |
25 | 25 | |
26 | 26 | |
27 | 27 | import sage.misc.misc as misc |
28 | | import sage.categories.all as cat |
29 | 28 | from sage.modules.matrix_morphism import MatrixMorphism |
| 29 | from sage.categories.morphism import Morphism |
30 | 30 | |
31 | 31 | # We also define other types of Hecke-module morphisms that aren't |
32 | 32 | # specified by a matrix. E.g., Hecke operators, or maybe morphisms on |
… |
… |
def is_HeckeModuleMorphism(x): |
39 | 39 | def is_HeckeModuleMorphism_matrix(x): |
40 | 40 | return isinstance(x, HeckeModuleMorphism_matrix) |
41 | 41 | |
42 | | class HeckeModuleMorphism(cat.Morphism): |
| 42 | class HeckeModuleMorphism(Morphism): |
43 | 43 | pass |
44 | 44 | |
45 | 45 | class HeckeModuleMorphism_matrix(MatrixMorphism, HeckeModuleMorphism): |
-
diff --git a/sage/modular/modsym/ambient.py b/sage/modular/modsym/ambient.py
a
|
b
|
class ModularSymbolsAmbient(space.Modula |
715 | 715 | """ |
716 | 716 | |
717 | 717 | MS = matrix_space.MatrixSpace(self.base_ring(), self.dimension(), M.dimension()) |
718 | | hom = hecke.HeckeModuleHomspace(self, M) |
| 718 | hom = self.Hom(M) |
719 | 719 | if self.dimension() == 0 or M.dimension() == 0: |
720 | 720 | A = MS(0) |
721 | 721 | phi = hom(A, "Heilbronn operator(%s,%s)"%(H,t)) |